fix crash on logout, change several logger.debug to verbose, adjustments to player cache generation, fixes to file scan manager, better handling disconnects, some refactoring, adjustments to intro UI, correct display of server state
This commit is contained in:
@@ -17,13 +17,13 @@ public class DownloadUi : Window, IDisposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Logger.Debug("Disposing " + nameof(DownloadUi));
|
||||
Logger.Verbose("Disposing " + nameof(DownloadUi));
|
||||
_windowSystem.RemoveWindow(this);
|
||||
}
|
||||
|
||||
public DownloadUi(WindowSystem windowSystem, Configuration pluginConfiguration, ApiController apiController, UiShared uiShared) : base("Mare Synchronos Downloads")
|
||||
{
|
||||
Logger.Debug("Creating " + nameof(DownloadUi));
|
||||
Logger.Verbose("Creating " + nameof(DownloadUi));
|
||||
_windowSystem = windowSystem;
|
||||
_pluginConfiguration = pluginConfiguration;
|
||||
_apiController = apiController;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace MareSynchronos.UI
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Logger.Debug("Disposing " + nameof(IntroUi));
|
||||
Logger.Verbose("Disposing " + nameof(IntroUi));
|
||||
|
||||
_windowSystem.RemoveWindow(this);
|
||||
}
|
||||
@@ -28,7 +28,7 @@ namespace MareSynchronos.UI
|
||||
public IntroUi(WindowSystem windowSystem, UiShared uiShared, Configuration pluginConfiguration,
|
||||
FileCacheManager fileCacheManager) : base("Mare Synchronos Setup")
|
||||
{
|
||||
Logger.Debug("Creating " + nameof(IntroUi));
|
||||
Logger.Verbose("Creating " + nameof(IntroUi));
|
||||
|
||||
_uiShared = uiShared;
|
||||
_pluginConfiguration = pluginConfiguration;
|
||||
@@ -61,10 +61,9 @@ namespace MareSynchronos.UI
|
||||
"Note that you will have to have Penumbra as well as Glamourer installed to use this plugin.");
|
||||
UiShared.TextWrapped("We will have to setup a few things first before you can start using this plugin. Click on next to continue.");
|
||||
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
|
||||
UiShared.TextWrapped("Note: Any modifications you have applied through anything but Penumbra cannot be shared and your character state on other clients " +
|
||||
"might look broken because of this. If you want to use this plugin you will have to move your mods to Penumbra.");
|
||||
ImGui.PopStyleColor();
|
||||
UiShared.ColorTextWrapped("Note: Any modifications you have applied through anything but Penumbra cannot be shared and your character state on other clients " +
|
||||
"might look broken because of this or others players mods might not apply on your end altogether. " +
|
||||
"If you want to use this plugin you will have to move your mods to Penumbra.", ImGuiColors.DalamudYellow);
|
||||
if (!_uiShared.DrawOtherPluginState()) return;
|
||||
ImGui.Separator();
|
||||
if (ImGui.Button("Next##toAgreement"))
|
||||
@@ -90,22 +89,16 @@ namespace MareSynchronos.UI
|
||||
UiShared.TextWrapped("If you are on a data capped internet connection, higher fees due to data usage depending on the amount of downloaded and uploaded mod files might occur. " +
|
||||
"Mod files will be compressed on up- and download to save on bandwidth usage. Due to varying up- and download speeds, changes in characters might not be visible immediately. " +
|
||||
"Files present on the service that already represent your active mod files will not be uploaded again.");
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
|
||||
UiShared.TextWrapped("The mod files you are uploading are confidential and will not be distributed to parties other than the ones who are requesting the exact same mod files. " +
|
||||
UiShared.ColorTextWrapped("The mod files you are uploading are confidential and will not be distributed to parties other than the ones who are requesting the exact same mod files. " +
|
||||
"Please think about who you are going to pair since it is unavoidable that they will receive and locally cache the necessary mod files that you have currently in use. " +
|
||||
"Locally cached mod files will have arbitrary file names to discourage attempts at replicating the original mod.");
|
||||
ImGui.PopStyleColor();
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
|
||||
UiShared.TextWrapped("The plugin creator tried their best to keep you secure. However, there is no guarantee for 100% security. Do not blindly pair your client with everyone.");
|
||||
ImGui.PopStyleColor();
|
||||
"Locally cached mod files will have arbitrary file names to discourage attempts at replicating the original mod.", ImGuiColors.DalamudRed);
|
||||
UiShared.ColorTextWrapped("The plugin creator tried their best to keep you secure. However, there is no guarantee for 100% security. Do not blindly pair your client with everyone.", ImGuiColors.DalamudYellow);
|
||||
UiShared.TextWrapped("Mod files that are saved on the service will remain on the service as long as there are requests for the files from clients. " +
|
||||
"After a period of not being used, the mod files will be automatically deleted. " +
|
||||
"You will also be able to wipe all the files you have personally uploaded on request. " +
|
||||
"The service holds no information about which mod files belong to which mod.");
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
|
||||
UiShared.TextWrapped("This service is provided as-is. In case of abuse, contact darkarchon#4313 on Discord or join the Mare Synchronos Discord. " +
|
||||
"To accept those conditions hold CTRL while clicking 'I agree'");
|
||||
ImGui.PopStyleColor();
|
||||
UiShared.ColorTextWrapped("This service is provided as-is. In case of abuse, contact darkarchon#4313 on Discord or join the Mare Synchronos Discord. " +
|
||||
"To accept those conditions hold CTRL while clicking 'I agree'", ImGuiColors.DalamudRed);
|
||||
ImGui.Separator();
|
||||
|
||||
if (ImGui.Button("I agree##toSetup"))
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace MareSynchronos.UI
|
||||
public MainUi(WindowSystem windowSystem,
|
||||
UiShared uiShared, Configuration configuration, ApiController apiController) : base("Mare Synchronos Settings", ImGuiWindowFlags.None)
|
||||
{
|
||||
Logger.Debug("Creating " + nameof(MainUi));
|
||||
Logger.Verbose("Creating " + nameof(MainUi));
|
||||
|
||||
SizeConstraints = new WindowSizeConstraints()
|
||||
{
|
||||
@@ -44,7 +44,7 @@ namespace MareSynchronos.UI
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Logger.Debug("Disposing " + nameof(MainUi));
|
||||
Logger.Verbose("Disposing " + nameof(MainUi));
|
||||
|
||||
_windowSystem.RemoveWindow(this);
|
||||
}
|
||||
@@ -66,11 +66,12 @@ namespace MareSynchronos.UI
|
||||
{
|
||||
_uiShared.PrintServerState();
|
||||
ImGui.Separator();
|
||||
ImGui.SetWindowFontScale(1.2f);
|
||||
ImGui.Text("Your UID");
|
||||
ImGui.SameLine();
|
||||
if (_apiController.IsConnected)
|
||||
|
||||
if (_apiController.ServerState is ServerState.Connected)
|
||||
{
|
||||
ImGui.SetWindowFontScale(1.2f);
|
||||
ImGui.Text("Your UID");
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(ImGuiColors.ParsedGreen, _apiController.UID);
|
||||
ImGui.SameLine();
|
||||
ImGui.SetWindowFontScale(1.0f);
|
||||
@@ -83,33 +84,44 @@ namespace MareSynchronos.UI
|
||||
}
|
||||
else
|
||||
{
|
||||
var error = _configuration.FullPause ? "Disconnected"
|
||||
: !_apiController.ServerAlive
|
||||
? "Service unavailable"
|
||||
: !_apiController.ServerSupportsThisClient
|
||||
? "Service version mismatch"
|
||||
: "Unauthorized";
|
||||
ImGui.TextColored(ImGuiColors.DalamudRed, $"No UID ({error})");
|
||||
string errorMsg = _apiController.ServerState switch
|
||||
{
|
||||
ServerState.Disconnected => "Disconnected",
|
||||
ServerState.Unauthorized => "Unauthorized",
|
||||
ServerState.VersionMisMatch => "Service version mismatch",
|
||||
ServerState.Offline => "Service unavailable"
|
||||
};
|
||||
ImGui.SetWindowFontScale(1.2f);
|
||||
ImGui.TextColored(ImGuiColors.DalamudRed, $"No UID ({errorMsg})");
|
||||
ImGui.SetWindowFontScale(1.0f);
|
||||
if (_apiController.ServerAlive && !_configuration.FullPause && _apiController.ServerSupportsThisClient)
|
||||
switch (_apiController.ServerState)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
|
||||
UiShared.TextWrapped("Your account is not present on the service anymore or you are banned.");
|
||||
ImGui.PopStyleColor();
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
|
||||
UiShared.TextWrapped("If you think your secret key is just invalid, use the following button to reset the local secret key to be able to re-register. If you continue to see this message after registering, tough luck, asshole.");
|
||||
ImGui.PopStyleColor();
|
||||
if (ImGui.Button("Reset Secret Key"))
|
||||
{
|
||||
_configuration.ClientSecret.Remove(_configuration.ApiUri);
|
||||
_configuration.Save();
|
||||
SwitchFromMainUiToIntro?.Invoke();
|
||||
}
|
||||
} else if (!_apiController.ServerSupportsThisClient)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
|
||||
UiShared.TextWrapped("The server or your client is outdated. If the client has recently been updated for breaking service changes, the service must follow suit.");
|
||||
ImGui.PopStyleColor();
|
||||
case ServerState.Disconnected:
|
||||
UiShared.ColorTextWrapped("You are currently disconnected from the Mare Synchronos service.", ImGuiColors.DalamudRed);
|
||||
break;
|
||||
case ServerState.Unauthorized:
|
||||
UiShared.ColorTextWrapped("Your account is not present on the service anymore or you are banned.", ImGuiColors.DalamudRed);
|
||||
UiShared.ColorTextWrapped("If you think your secret key is just invalid, use the following button to reset " +
|
||||
"the local secret key to be able to re-register. If you continue to see this message after " +
|
||||
"registering, tough luck, asshole.", ImGuiColors.DalamudYellow);
|
||||
if (ImGui.Button("Reset Secret Key"))
|
||||
{
|
||||
_configuration.ClientSecret.Remove(_configuration.ApiUri);
|
||||
_configuration.Save();
|
||||
SwitchFromMainUiToIntro?.Invoke();
|
||||
}
|
||||
break;
|
||||
case ServerState.Offline:
|
||||
UiShared.ColorTextWrapped("Your selected Mare Synchronos server is currently offline.", ImGuiColors.DalamudRed);
|
||||
break;
|
||||
case ServerState.VersionMisMatch:
|
||||
UiShared.ColorTextWrapped("The server or your client is outdated. If the client has recently been updated for breaking " +
|
||||
"service changes, the service must follow suit.", ImGuiColors.DalamudRed);
|
||||
break;
|
||||
case ServerState.Connected:
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,9 +477,7 @@ namespace MareSynchronos.UI
|
||||
|
||||
if (!_configuration.FullPause)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
|
||||
UiShared.TextWrapped("Note: to change servers you need to disconnect from your current Mare Synchronos server.");
|
||||
ImGui.PopStyleColor();
|
||||
UiShared.ColorTextWrapped("Note: to change servers you need to disconnect from your current Mare Synchronos server.", ImGuiColors.DalamudYellow);
|
||||
}
|
||||
|
||||
var marePaused = _configuration.FullPause;
|
||||
@@ -485,18 +495,14 @@ namespace MareSynchronos.UI
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
|
||||
ImGui.TextUnformatted("You cannot reconnect without a valid account on the service.");
|
||||
ImGui.PopStyleColor();
|
||||
UiShared.ColorText("You cannot reconnect without a valid account on the service.", ImGuiColors.DalamudYellow);
|
||||
}
|
||||
|
||||
|
||||
if (marePaused)
|
||||
{
|
||||
_uiShared.DrawServiceSelection(() => SwitchFromMainUiToIntro?.Invoke());
|
||||
}
|
||||
|
||||
|
||||
ImGui.TreePop();
|
||||
}
|
||||
}
|
||||
@@ -506,11 +512,10 @@ namespace MareSynchronos.UI
|
||||
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. " +
|
||||
UiShared.ColorTextWrapped("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();
|
||||
"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.",
|
||||
ImGuiColors.DalamudGrey);
|
||||
|
||||
if (ImGui.BeginTable("TransfersTable", 2, ImGuiTableFlags.SizingStretchProp))
|
||||
{
|
||||
@@ -579,7 +584,7 @@ namespace MareSynchronos.UI
|
||||
ImGui.TableSetupColumn("Uploaded");
|
||||
ImGui.TableSetupColumn("Size");
|
||||
ImGui.TableHeadersRow();
|
||||
foreach (var transfer in _apiController.CurrentUploads)
|
||||
foreach (var transfer in _apiController.CurrentUploads.ToArray())
|
||||
{
|
||||
var color = UiShared.UploadColor((transfer.Transferred, transfer.Total));
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, color);
|
||||
@@ -603,7 +608,7 @@ namespace MareSynchronos.UI
|
||||
ImGui.TableSetupColumn("Downloaded");
|
||||
ImGui.TableSetupColumn("Size");
|
||||
ImGui.TableHeadersRow();
|
||||
foreach (var transfer in _apiController.CurrentDownloads)
|
||||
foreach (var transfer in _apiController.CurrentDownloads.ToArray())
|
||||
{
|
||||
var color = UiShared.UploadColor((transfer.Transferred, transfer.Total));
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, color);
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace MareSynchronos.UI
|
||||
_fileDialogManager = fileDialogManager;
|
||||
_pluginConfiguration = pluginConfiguration;
|
||||
_dalamudUtil = dalamudUtil;
|
||||
isDirectoryWritable = IsDirectoryWritable(_pluginConfiguration.CacheFolder);
|
||||
_isDirectoryWritable = IsDirectoryWritable(_pluginConfiguration.CacheFolder);
|
||||
}
|
||||
|
||||
public bool DrawOtherPluginState()
|
||||
@@ -85,7 +85,7 @@ namespace MareSynchronos.UI
|
||||
var serverName = _apiController.ServerDictionary.ContainsKey(_pluginConfiguration.ApiUri)
|
||||
? _apiController.ServerDictionary[_pluginConfiguration.ApiUri]
|
||||
: _pluginConfiguration.ApiUri;
|
||||
ImGui.Text("Service " + serverName + ":");
|
||||
ImGui.TextUnformatted("Service " + serverName + ":");
|
||||
ImGui.SameLine();
|
||||
var color = _apiController.ServerAlive ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed;
|
||||
ImGui.TextColored(color, _apiController.ServerAlive ? "Available" : "Unavailable");
|
||||
@@ -102,6 +102,20 @@ namespace MareSynchronos.UI
|
||||
}
|
||||
}
|
||||
|
||||
public static void ColorText(string text, Vector4 color)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, color);
|
||||
ImGui.TextUnformatted(text);
|
||||
ImGui.PopStyleColor();
|
||||
}
|
||||
|
||||
public static void ColorTextWrapped(string text, Vector4 color)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, color);
|
||||
TextWrapped(text);
|
||||
ImGui.PopStyleColor();
|
||||
}
|
||||
|
||||
public static void TextWrapped(string text)
|
||||
{
|
||||
ImGui.PushTextWrapPos(0);
|
||||
@@ -238,9 +252,7 @@ namespace MareSynchronos.UI
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
|
||||
TextWrapped("You already have an account on this server.");
|
||||
ImGui.PopStyleColor();
|
||||
ColorTextWrapped("You already have an account on this server.", ImGuiColors.DalamudYellow);
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Connect##connectToService"))
|
||||
{
|
||||
@@ -301,7 +313,7 @@ namespace MareSynchronos.UI
|
||||
_pluginConfiguration.CacheFolder = cacheDirectory;
|
||||
if (!string.IsNullOrEmpty(_pluginConfiguration.CacheFolder)
|
||||
&& Directory.Exists(_pluginConfiguration.CacheFolder)
|
||||
&& (isDirectoryWritable = IsDirectoryWritable(_pluginConfiguration.CacheFolder)))
|
||||
&& (_isDirectoryWritable = IsDirectoryWritable(_pluginConfiguration.CacheFolder)))
|
||||
{
|
||||
_pluginConfiguration.Save();
|
||||
_fileCacheManager.StartWatchers();
|
||||
@@ -318,8 +330,8 @@ namespace MareSynchronos.UI
|
||||
if (!success) return;
|
||||
|
||||
_pluginConfiguration.CacheFolder = path;
|
||||
isDirectoryWritable = IsDirectoryWritable(_pluginConfiguration.CacheFolder);
|
||||
if (isDirectoryWritable)
|
||||
_isDirectoryWritable = IsDirectoryWritable(_pluginConfiguration.CacheFolder);
|
||||
if (_isDirectoryWritable)
|
||||
{
|
||||
_pluginConfiguration.Save();
|
||||
_fileCacheManager.StartWatchers();
|
||||
@@ -328,15 +340,13 @@ namespace MareSynchronos.UI
|
||||
}
|
||||
ImGui.PopFont();
|
||||
|
||||
if (!Directory.Exists(cacheDirectory) || !isDirectoryWritable)
|
||||
if (!Directory.Exists(cacheDirectory) || !_isDirectoryWritable)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
|
||||
TextWrapped("The folder you selected does not exist or cannot be written to. Please provide a valid path.");
|
||||
ImGui.PopStyleColor();
|
||||
ColorTextWrapped("The folder you selected does not exist or cannot be written to. Please provide a valid path.", ImGuiColors.DalamudRed);
|
||||
}
|
||||
}
|
||||
|
||||
private bool isDirectoryWritable = false;
|
||||
private bool _isDirectoryWritable = false;
|
||||
|
||||
public bool IsDirectoryWritable(string dirPath, bool throwIfFails = false)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user