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

@@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<Authors></Authors> <Authors></Authors>
<Company></Company> <Company></Company>
<Version>0.0.6.0</Version> <Version>0.0.7.0</Version>
<Description></Description> <Description></Description>
<Copyright></Copyright> <Copyright></Copyright>
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl> <PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>

View File

@@ -127,7 +127,7 @@ namespace MareSynchronos.UI
_uiShared.DrawCacheDirectorySetting(); _uiShared.DrawCacheDirectorySetting();
if (!_fileCacheManager.IsScanRunning) if (!_fileCacheManager.IsScanRunning && !string.IsNullOrEmpty(_pluginConfiguration.CacheFolder))
{ {
UiShared.TextWrapped("You can adjust how many parallel threads will be used for scanning. Mind that ultimately it will depend on the amount of mods, your disk speed and your CPU. " + UiShared.TextWrapped("You can adjust how many parallel threads will be used for scanning. Mind that ultimately it will depend on the amount of mods, your disk speed and your CPU. " +
"More is not necessarily better, the default of 10 should be fine for most cases."); "More is not necessarily better, the default of 10 should be fine for most cases.");

View File

@@ -89,7 +89,8 @@ namespace MareSynchronos.UI
ServerState.Disconnected => "Disconnected", ServerState.Disconnected => "Disconnected",
ServerState.Unauthorized => "Unauthorized", ServerState.Unauthorized => "Unauthorized",
ServerState.VersionMisMatch => "Service version mismatch", ServerState.VersionMisMatch => "Service version mismatch",
ServerState.Offline => "Service unavailable" ServerState.Offline => "Service unavailable",
ServerState.NoAccount => "No account",
}; };
ImGui.SetWindowFontScale(1.2f); ImGui.SetWindowFontScale(1.2f);
ImGui.TextColored(ImGuiColors.DalamudRed, $"No UID ({errorMsg})"); ImGui.TextColored(ImGuiColors.DalamudRed, $"No UID ({errorMsg})");

View File

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