rework a lot of stuff: downloads, how to watch a player

This commit is contained in:
Stanley Dimant
2022-06-30 13:24:35 +02:00
parent eb39429777
commit 3618540402
18 changed files with 319 additions and 233 deletions

View File

@@ -52,10 +52,11 @@ public class DownloadUi : Window, IDisposable
if (_apiController.CurrentUploads.Any())
{
var doneUploads = _apiController.CurrentUploads.Count(c => c.Total == c.Transferred);
var totalUploads = _apiController.CurrentUploads.Count;
var totalUploaded = _apiController.CurrentUploads.Sum(c => c.Transferred);
var totalToUpload = _apiController.CurrentUploads.Sum(c => c.Total);
var currentUploads = _apiController.CurrentUploads.ToList();
var doneUploads = currentUploads.Count(c => c.IsTransferred);
var totalUploads = currentUploads.Count;
var totalUploaded = currentUploads.Sum(c => c.Transferred);
var totalToUpload = currentUploads.Sum(c => c.Total);
UiShared.DrawOutlinedFont(drawList, "▲",
new Vector2(basePosition.X + 0, basePosition.Y + (int)(yDistance * 0.5)),
UiShared.Color(255, 255, 255, 255), UiShared.Color(0, 0, 0, 255), 2);
@@ -69,11 +70,12 @@ public class DownloadUi : Window, IDisposable
if (_apiController.CurrentDownloads.Any())
{
var multBase = _apiController.CurrentUploads.Any() ? 0 : 2;
var doneDownloads = _apiController.CurrentDownloads.Count(c => c.Total == c.Transferred);
var totalDownloads = _apiController.CurrentDownloads.Count;
var totalDownloaded = _apiController.CurrentDownloads.Sum(c => c.Transferred);
var totalToDownload = _apiController.CurrentDownloads.Sum(c => c.Total);
var currentDownloads = _apiController.CurrentDownloads.ToList();
var multBase = currentDownloads.Any() ? 0 : 2;
var doneDownloads = currentDownloads.Count(c => c.IsTransferred);
var totalDownloads = currentDownloads.Count;
var totalDownloaded = currentDownloads.Sum(c => c.Transferred);
var totalToDownload = currentDownloads.Sum(c => c.Total);
UiShared.DrawOutlinedFont(drawList, "▼",
new Vector2(basePosition.X + 0, basePosition.Y + (int)(yDistance * multBase + (yDistance * 0.5))),
UiShared.Color(255, 255, 255, 255), UiShared.Color(0, 0, 0, 255), 2);

View File

@@ -132,7 +132,7 @@ namespace MareSynchronos.UI
ImGui.TableHeadersRow();
foreach (var forbiddenFile in _apiController.ForbiddenFiles)
foreach (var forbiddenFile in _apiController.AdminForbiddenFiles)
{
ImGui.TableNextColumn();
@@ -203,7 +203,7 @@ namespace MareSynchronos.UI
ImGui.TableHeadersRow();
foreach (var bannedUser in _apiController.BannedUsers)
foreach (var bannedUser in _apiController.AdminBannedUsers)
{
ImGui.TableNextColumn();
ImGui.Text(bannedUser.CharacterHash);
@@ -581,7 +581,7 @@ namespace MareSynchronos.UI
File.Delete(file);
}
_uiShared.ForceRescan();
//_uiShared.ForceRescan();
});
}
ImGui.TreePop();

View File

@@ -32,6 +32,7 @@ namespace MareSynchronos.UI
_fileDialogManager = fileDialogManager;
_pluginConfiguration = pluginConfiguration;
_dalamudUtil = dalamudUtil;
isDirectoryWritable = IsDirectoryWritable(_pluginConfiguration.CacheFolder);
}
public bool DrawOtherPluginState()
@@ -58,11 +59,6 @@ namespace MareSynchronos.UI
return true;
}
public void ForceRescan()
{
Task.Run(() => _ = _fileCacheManager.RescanTask(true));
}
public void DrawFileScanState()
{
ImGui.Text("File Scanner Status");
@@ -300,7 +296,9 @@ namespace MareSynchronos.UI
if (ImGui.InputText("Cache Folder##cache", ref cacheDirectory, 255))
{
_pluginConfiguration.CacheFolder = cacheDirectory;
if (!string.IsNullOrEmpty(_pluginConfiguration.CacheFolder) && Directory.Exists(_pluginConfiguration.CacheFolder))
if (!string.IsNullOrEmpty(_pluginConfiguration.CacheFolder)
&& Directory.Exists(_pluginConfiguration.CacheFolder)
&& (isDirectoryWritable = IsDirectoryWritable(_pluginConfiguration.CacheFolder)))
{
_pluginConfiguration.Save();
_fileCacheManager.StartWatchers();
@@ -317,20 +315,26 @@ namespace MareSynchronos.UI
if (!success) return;
_pluginConfiguration.CacheFolder = path;
_pluginConfiguration.Save();
_fileCacheManager.StartWatchers();
isDirectoryWritable = IsDirectoryWritable(_pluginConfiguration.CacheFolder);
if (isDirectoryWritable)
{
_pluginConfiguration.Save();
_fileCacheManager.StartWatchers();
}
});
}
ImGui.PopFont();
if (!Directory.Exists(cacheDirectory) || !IsDirectoryWritable(cacheDirectory))
if (!Directory.Exists(cacheDirectory) || !isDirectoryWritable)
{
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
TextWrapped("The folder you selected does not exist. Please provide a valid path.");
TextWrapped("The folder you selected does not exist or cannot be written to. Please provide a valid path.");
ImGui.PopStyleColor();
}
}
private bool isDirectoryWritable = false;
public bool IsDirectoryWritable(string dirPath, bool throwIfFails = false)
{
try