make download ui clickthrough, add option to move it, add forbidden transfers list
This commit is contained in:
@@ -121,6 +121,11 @@ public class CachedPlayer
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((TryCalculateModdedDictionary(_cache[_lastAppliedEquipmentHash], out moddedPaths)).All(c => _apiController.ForbiddenTransfers.Any(f => f.Hash == c.Hash)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ApplyCharacterData(_cache[_lastAppliedEquipmentHash], moddedPaths);
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace MareSynchronos
|
||||
_fileCacheManager.StartWatchers();
|
||||
ReLaunchCharacterManager();
|
||||
};
|
||||
_downloadUi = new DownloadUi(_windowSystem, _configuration, _apiController);
|
||||
_downloadUi = new DownloadUi(_windowSystem, _configuration, _apiController, uiSharedComponent);
|
||||
|
||||
|
||||
_dalamudUtil.LogIn += DalamudUtilOnLogIn;
|
||||
|
||||
@@ -13,6 +13,7 @@ public class DownloadUi : Window, IDisposable
|
||||
private readonly WindowSystem _windowSystem;
|
||||
private readonly Configuration _pluginConfiguration;
|
||||
private readonly ApiController _apiController;
|
||||
private readonly UiShared _uiShared;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
@@ -20,12 +21,13 @@ public class DownloadUi : Window, IDisposable
|
||||
_windowSystem.RemoveWindow(this);
|
||||
}
|
||||
|
||||
public DownloadUi(WindowSystem windowSystem, Configuration pluginConfiguration, ApiController apiController) : base("Mare Synchronos Downloads")
|
||||
public DownloadUi(WindowSystem windowSystem, Configuration pluginConfiguration, ApiController apiController, UiShared uiShared) : base("Mare Synchronos Downloads")
|
||||
{
|
||||
Logger.Debug("Creating " + nameof(DownloadUi));
|
||||
_windowSystem = windowSystem;
|
||||
_pluginConfiguration = pluginConfiguration;
|
||||
_apiController = apiController;
|
||||
_uiShared = uiShared;
|
||||
|
||||
SizeConstraints = new WindowSizeConstraints()
|
||||
{
|
||||
@@ -33,12 +35,38 @@ public class DownloadUi : Window, IDisposable
|
||||
MinimumSize = new Vector2(300, 90)
|
||||
};
|
||||
|
||||
Flags = ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoBackground;
|
||||
Flags |= ImGuiWindowFlags.NoMove;
|
||||
Flags |= ImGuiWindowFlags.NoBackground;
|
||||
Flags |= ImGuiWindowFlags.NoInputs;
|
||||
Flags |= ImGuiWindowFlags.NoNavFocus;
|
||||
Flags |= ImGuiWindowFlags.NoResize;
|
||||
Flags |= ImGuiWindowFlags.NoScrollbar;
|
||||
Flags |= ImGuiWindowFlags.NoTitleBar;
|
||||
Flags |= ImGuiWindowFlags.NoDecoration;
|
||||
|
||||
windowSystem.AddWindow(this);
|
||||
IsOpen = true;
|
||||
}
|
||||
|
||||
public override void PreDraw()
|
||||
{
|
||||
base.PreDraw();
|
||||
if (_uiShared.EditTrackerPosition)
|
||||
{
|
||||
Flags &= ~ImGuiWindowFlags.NoMove;
|
||||
Flags &= ~ImGuiWindowFlags.NoBackground;
|
||||
Flags &= ~ImGuiWindowFlags.NoInputs;
|
||||
Flags &= ~ImGuiWindowFlags.NoResize;
|
||||
}
|
||||
else
|
||||
{
|
||||
Flags |= ImGuiWindowFlags.NoMove;
|
||||
Flags |= ImGuiWindowFlags.NoBackground;
|
||||
Flags |= ImGuiWindowFlags.NoInputs;
|
||||
Flags |= ImGuiWindowFlags.NoResize;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
if (!_pluginConfiguration.ShowTransferWindow) return;
|
||||
|
||||
@@ -7,10 +7,12 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Mime;
|
||||
using System.Numerics;
|
||||
using System.Threading.Tasks;
|
||||
using MareSynchronos.API;
|
||||
using MareSynchronos.Utils;
|
||||
using MareSynchronos.WebAPI.Utils;
|
||||
|
||||
namespace MareSynchronos.UI
|
||||
{
|
||||
@@ -108,6 +110,7 @@ namespace MareSynchronos.UI
|
||||
DrawFileCacheSettings();
|
||||
if (_apiController.IsConnected)
|
||||
DrawCurrentTransfers();
|
||||
DrawBlockedTransfers();
|
||||
DrawUserAdministration(_apiController.IsConnected);
|
||||
if (_apiController.IsConnected && _apiController.IsModerator)
|
||||
DrawAdministration();
|
||||
@@ -489,6 +492,46 @@ namespace MareSynchronos.UI
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawBlockedTransfers()
|
||||
{
|
||||
if (ImGui.TreeNode(
|
||||
$"Forbidden Transfers"))
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudGrey);
|
||||
UiShared.TextWrapped("Files that you attempted to upload or download that were forbidden to be transferred by their creators will appear here. " +
|
||||
"If you see file paths from your drive here, then those files were not allowed to be uploaded. If you see hashes, those files were not allowed to be downloaded. " +
|
||||
"Ask your paired friend to send you the mod in question through other means, acquire the mod yourself or pester the mod creator to allow it to be sent over Mare.");
|
||||
ImGui.PopStyleColor();
|
||||
|
||||
if (ImGui.BeginTable("TransfersTable", 2, ImGuiTableFlags.SizingStretchProp))
|
||||
{
|
||||
ImGui.TableSetupColumn(
|
||||
$"Hash/Filename");
|
||||
ImGui.TableSetupColumn($"Forbidden by");
|
||||
|
||||
ImGui.TableHeadersRow();
|
||||
|
||||
foreach (var item in _apiController.ForbiddenTransfers)
|
||||
{
|
||||
ImGui.TableNextColumn();
|
||||
if (item is UploadFileTransfer transfer)
|
||||
{
|
||||
ImGui.Text(transfer.LocalFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.Text(item.Hash);
|
||||
}
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text(item.ForbiddenBy);
|
||||
}
|
||||
ImGui.EndTable();
|
||||
}
|
||||
|
||||
ImGui.TreePop();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCurrentTransfers()
|
||||
{
|
||||
if (ImGui.TreeNode(
|
||||
@@ -501,6 +544,17 @@ namespace MareSynchronos.UI
|
||||
_configuration.Save();
|
||||
}
|
||||
|
||||
if (_configuration.ShowTransferWindow)
|
||||
{
|
||||
ImGui.Indent();
|
||||
bool editTransferWindowPosition = _uiShared.EditTrackerPosition;
|
||||
if (ImGui.Checkbox("Edit Transfer Window position", ref editTransferWindowPosition))
|
||||
{
|
||||
_uiShared.EditTrackerPosition = editTransferWindowPosition;
|
||||
}
|
||||
ImGui.Unindent();
|
||||
}
|
||||
|
||||
if (ImGui.BeginTable("TransfersTable", 2))
|
||||
{
|
||||
ImGui.TableSetupColumn(
|
||||
@@ -580,14 +634,18 @@ namespace MareSynchronos.UI
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
|
||||
//_uiShared.ForceRescan();
|
||||
});
|
||||
}
|
||||
ImGui.TreePop();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
_uiShared.EditTrackerPosition = false;
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
private void DrawPairedClientsContent()
|
||||
{
|
||||
if (!_apiController.ServerAlive) return;
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace MareSynchronos.UI
|
||||
public long FileCacheSize => _fileCacheManager.FileCacheSize;
|
||||
public bool ShowClientSecret = true;
|
||||
public string PlayerName => _dalamudUtil.PlayerName;
|
||||
public bool EditTrackerPosition { get; set; }
|
||||
|
||||
public UiShared(IpcManager ipcManager, ApiController apiController, FileCacheManager fileCacheManager, FileDialogManager fileDialogManager, Configuration pluginConfiguration, DalamudUtil dalamudUtil)
|
||||
{
|
||||
_ipcManager = ipcManager;
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace MareSynchronos.WebAPI
|
||||
await Task.Delay(250, ct);
|
||||
}
|
||||
|
||||
CurrentDownloads.RemoveAll(d => d.Transferred == d.Total);
|
||||
CurrentDownloads.RemoveAll(d => d.Transferred == d.Total || !d.CanBeTransferred);
|
||||
}
|
||||
|
||||
public async Task PushCharacterData(CharacterCacheDto character, List<string> visibleCharacterIds)
|
||||
@@ -153,11 +153,17 @@ namespace MareSynchronos.WebAPI
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var file in CurrentUploads.Where(c => c.IsForbidden))
|
||||
await using (var db = new FileCacheContext())
|
||||
{
|
||||
if (ForbiddenTransfers.All(f => f.Hash != file.Hash))
|
||||
foreach (var file in filesToUpload.Where(c => c.IsForbidden))
|
||||
{
|
||||
ForbiddenTransfers.Add(file);
|
||||
if (ForbiddenTransfers.All(f => f.Hash != file.Hash))
|
||||
{
|
||||
ForbiddenTransfers.Add(new UploadFileTransfer(file)
|
||||
{
|
||||
LocalFile = db.FileCaches.FirstOrDefault(f => f.Hash == file.Hash)?.Filepath ?? string.Empty
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ public class UploadFileTransfer : FileTransfer
|
||||
{
|
||||
public UploadFileTransfer(UploadFileDto dto) : base(dto) { }
|
||||
public override long Total { get; set; }
|
||||
public string LocalFile { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class DownloadFileTransfer : FileTransfer
|
||||
|
||||
Reference in New Issue
Block a user