[Draft] Update 0.8 (#46)

* move stuff out into file transfer manager

* obnoxious unsupported version text, adjustments to filetransfermanager

* add back file upload transfer progress

* restructure code

* cleanup some more stuff I guess

* downloadids by playername

* individual anim/sound bs

* fix migration stuff, finalize impl of individual sound/anim pause

* fixes with logging stuff

* move download manager to transient

* rework dl ui first iteration

* some refactoring and cleanup

* more code cleanup

* refactoring

* switch to hostbuilder

* some more rework I guess

* more refactoring

* clean up mediator calls and disposal

* fun code cleanup

* push error message when log level is set to anything but information in non-debug builds

* remove notificationservice

* move message to after login

* add download bars to gameworld

* fixes download progress bar

* set gpose ui min and max size

* remove unnecessary usings

* adjustments to reconnection logic

* add options to set visible/offline groups visibility

* add impl of uploading display, transfer list in settings ui

* attempt to fix issues with server selection

* add back download status to compact ui

* make dl bar fixed size based

* some fixes for upload/download handling

* adjust text from Syncing back to Uploading

---------

Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
Co-authored-by: Stanley Dimant <stanley.dimant@varian.com>
This commit is contained in:
rootdarkarchon
2023-03-14 19:48:35 +01:00
committed by GitHub
parent 0824ba434b
commit 0c87e84f25
109 changed files with 7323 additions and 6488 deletions

View File

@@ -1,126 +1,117 @@
using System.Diagnostics;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Globalization;
using System.Numerics;
using System.Reflection;
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Components;
using Dalamud.Interface.Windowing;
using Dalamud.Utility;
using ImGuiNET;
using MareSynchronos.API.Data.Extensions;
using MareSynchronos.API.Dto.User;
using MareSynchronos.Managers;
using MareSynchronos.MareConfiguration;
using MareSynchronos.Mediator;
using MareSynchronos.Models;
using MareSynchronos.PlayerData.Handlers;
using MareSynchronos.PlayerData.Pairs;
using MareSynchronos.Services.Mediator;
using MareSynchronos.Services.ServerConfiguration;
using MareSynchronos.UI.Components;
using MareSynchronos.UI.Handlers;
using MareSynchronos.WebAPI;
using MareSynchronos.WebAPI.Files;
using MareSynchronos.WebAPI.Files.Models;
using MareSynchronos.WebAPI.SignalR.Utils;
using Microsoft.Extensions.Logging;
namespace MareSynchronos.UI;
public class CompactUi : WindowMediatorSubscriberBase, IDisposable
public class CompactUi : WindowMediatorSubscriberBase
{
private readonly ApiController _apiController;
private readonly PairManager _pairManager;
private readonly ServerConfigurationManager _serverManager;
private readonly MareConfigService _configService;
private readonly TagHandler _tagHandler;
public readonly Dictionary<string, bool> ShowUidForEntry = new(StringComparer.Ordinal);
private readonly UiShared _uiShared;
private readonly WindowSystem _windowSystem;
private string _characterOrCommentFilter = string.Empty;
public string EditUserComment = string.Empty;
public string EditNickEntry = string.Empty;
private string _pairToAdd = string.Empty;
private readonly Stopwatch _timeout = new();
private bool _buttonState;
public string EditUserComment = string.Empty;
public float TransferPartHeight;
public float WindowContentWidth;
private bool _showModalForUserAddition;
private bool _wasOpen;
private bool _showSyncShells;
private readonly ApiController _apiController;
private readonly MareConfigService _configService;
private readonly ConcurrentDictionary<GameObjectHandler, Dictionary<string, FileDownloadStatus>> _currentDownloads = new();
private readonly FileUploadManager _fileTransferManager;
private readonly GroupPanel _groupPanel;
private Pair? _lastAddedUser;
private string _lastAddedUserComment = string.Empty;
private readonly PairGroupsUi _pairGroupsUi;
private readonly PairManager _pairManager;
private readonly SelectGroupForPairUi _selectGroupForPairUi;
private readonly SelectPairForGroupUi _selectPairsForGroupUi;
private readonly PairGroupsUi _pairGroupsUi;
private readonly ServerConfigurationManager _serverManager;
private readonly Stopwatch _timeout = new();
private readonly UiSharedService _uiShared;
private bool _buttonState;
private string _characterOrCommentFilter = string.Empty;
private Pair? _lastAddedUser;
private string _lastAddedUserComment = string.Empty;
private string _pairToAdd = string.Empty;
private int _secretKeyIdx = 0;
private bool _showModalForUserAddition;
private bool _showSyncShells;
private bool _wasOpen;
public CompactUi(ILogger<CompactUi> logger, WindowSystem windowSystem,
UiShared uiShared, MareConfigService configService, ApiController apiController, PairManager pairManager,
ServerConfigurationManager serverManager, MareMediator mediator) : base(logger, mediator, "###MareSynchronosMainUI")
public CompactUi(ILogger<CompactUi> logger, UiSharedService uiShared, MareConfigService configService, ApiController apiController, PairManager pairManager,
ServerConfigurationManager serverManager, MareMediator mediator, FileUploadManager fileTransferManager) : base(logger, mediator, "###MareSynchronosMainUI")
{
#if DEBUG
string dev = "Dev Build";
var ver = Assembly.GetExecutingAssembly().GetName().Version;
this.WindowName = $"Mare Synchronos {dev} ({ver.Major}.{ver.Minor}.{ver.Build})###MareSynchronosMainUI";
Toggle();
#else
var ver = Assembly.GetExecutingAssembly().GetName().Version;
this.WindowName = "Mare Synchronos " + ver.Major + "." + ver.Minor + "." + ver.Build + "###MareSynchronosMainUI";
#endif
_logger.LogTrace("Creating " + nameof(CompactUi));
_windowSystem = windowSystem;
_uiShared = uiShared;
_configService = configService;
_apiController = apiController;
_pairManager = pairManager;
_serverManager = serverManager;
_tagHandler = new(_serverManager);
_fileTransferManager = fileTransferManager;
var tagHandler = new TagHandler(_serverManager);
_groupPanel = new(this, uiShared, _pairManager, _serverManager, _configService);
_selectGroupForPairUi = new(_tagHandler);
_selectPairsForGroupUi = new(_tagHandler);
_pairGroupsUi = new(_tagHandler, DrawPairedClient, apiController, _selectPairsForGroupUi);
_selectGroupForPairUi = new(tagHandler);
_selectPairsForGroupUi = new(tagHandler);
_pairGroupsUi = new(configService, tagHandler, DrawPairedClient, apiController, _selectPairsForGroupUi);
#if DEBUG
string dev = "Dev Build";
var ver = Assembly.GetExecutingAssembly().GetName().Version!;
WindowName = $"Mare Synchronos {dev} ({ver.Major}.{ver.Minor}.{ver.Build})###MareSynchronosMainUI";
Toggle();
#else
var ver = Assembly.GetExecutingAssembly().GetName().Version;
WindowName = "Mare Synchronos " + ver.Major + "." + ver.Minor + "." + ver.Build + "###MareSynchronosMainUI";
#endif
Mediator.Subscribe<SwitchToMainUiMessage>(this, (_) => IsOpen = true);
Mediator.Subscribe<SwitchToIntroUiMessage>(this, (_) => IsOpen = false);
Mediator.Subscribe<CutsceneStartMessage>(this, (_) => UiShared_GposeStart());
Mediator.Subscribe<CutsceneEndMessage>(this, (_) => UiShared_GposeEnd());
Mediator.Subscribe<CutsceneStartMessage>(this, (_) => UiSharedService_GposeStart());
Mediator.Subscribe<CutsceneEndMessage>(this, (_) => UiSharedService_GposeEnd());
Mediator.Subscribe<DownloadStartedMessage>(this, (msg) => _currentDownloads[msg.DownloadId] = msg.DownloadStatus);
Mediator.Subscribe<DownloadFinishedMessage>(this, (msg) => _currentDownloads.TryRemove(msg.DownloadId, out _));
SizeConstraints = new WindowSizeConstraints()
{
MinimumSize = new Vector2(350, 400),
MaximumSize = new Vector2(350, 2000),
};
windowSystem.AddWindow(this);
}
private void UiShared_GposeEnd()
{
IsOpen = _wasOpen;
}
private void UiShared_GposeStart()
{
_wasOpen = IsOpen;
IsOpen = false;
}
public override void Dispose()
{
base.Dispose();
_windowSystem.RemoveWindow(this);
}
public override void Draw()
{
WindowContentWidth = UiShared.GetWindowContentRegionWidth();
UiShared.DrawWithID("header", DrawUIDHeader);
WindowContentWidth = UiSharedService.GetWindowContentRegionWidth();
if (!_apiController.IsCurrentVersion)
{
var ver = _apiController.CurrentClientVersion;
if (_uiShared.UidFontBuilt) ImGui.PushFont(_uiShared.UidFont);
var unsupported = "UNSUPPORTED VERSION";
var uidTextSize = ImGui.CalcTextSize(unsupported);
ImGui.SetCursorPosX((ImGui.GetWindowContentRegionMax().X + ImGui.GetWindowContentRegionMin().X) / 2 - uidTextSize.X / 2);
ImGui.TextColored(ImGuiColors.DalamudRed, unsupported);
if (_uiShared.UidFontBuilt) ImGui.PopFont();
UiSharedService.ColorTextWrapped($"Your Mare Synchronos installation is out of date, the current version is {ver.Major}.{ver.Minor}.{ver.Build}. " +
$"It is highly recommended to keep Mare Synchronos up to date. Open /xlplugins and update the plugin.", ImGuiColors.DalamudRed);
}
UiSharedService.DrawWithID("header", DrawUIDHeader);
ImGui.Separator();
UiShared.DrawWithID("serverstatus", DrawServerStatus);
UiSharedService.DrawWithID("serverstatus", DrawServerStatus);
if (_apiController.ServerState is ServerState.Connected)
{
@@ -131,7 +122,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
{
ImGui.PushStyleColor(ImGuiCol.Button, ImGui.GetStyle().Colors[(int)ImGuiCol.ButtonHovered]);
}
if (ImGui.Button(FontAwesomeIcon.User.ToIconString(), new Vector2((UiShared.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X) / 2, 30 * ImGuiHelpers.GlobalScale)))
if (ImGui.Button(FontAwesomeIcon.User.ToIconString(), new Vector2((UiSharedService.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X) / 2, 30 * ImGuiHelpers.GlobalScale)))
{
_showSyncShells = false;
}
@@ -140,7 +131,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
ImGui.PopStyleColor();
}
ImGui.PopFont();
UiShared.AttachToolTip("Individual pairs");
UiSharedService.AttachToolTip("Individual pairs");
ImGui.SameLine();
@@ -149,7 +140,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
{
ImGui.PushStyleColor(ImGuiCol.Button, ImGui.GetStyle().Colors[(int)ImGuiCol.ButtonHovered]);
}
if (ImGui.Button(FontAwesomeIcon.UserFriends.ToIconString(), new Vector2((UiShared.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X) / 2, 30 * ImGuiHelpers.GlobalScale)))
if (ImGui.Button(FontAwesomeIcon.UserFriends.ToIconString(), new Vector2((UiSharedService.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X) / 2, 30 * ImGuiHelpers.GlobalScale)))
{
_showSyncShells = true;
}
@@ -159,23 +150,22 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
}
ImGui.PopFont();
UiShared.AttachToolTip("Syncshells");
UiSharedService.AttachToolTip("Syncshells");
ImGui.Separator();
if (!hasShownSyncShells)
{
UiShared.DrawWithID("pairlist", DrawPairList);
UiSharedService.DrawWithID("pairlist", DrawPairList);
}
else
{
UiShared.DrawWithID("syncshells", _groupPanel.DrawSyncshells);
UiSharedService.DrawWithID("syncshells", _groupPanel.DrawSyncshells);
}
ImGui.Separator();
UiShared.DrawWithID("transfers", DrawTransfers);
UiSharedService.DrawWithID("transfers", DrawTransfers);
TransferPartHeight = ImGui.GetCursorPosY() - TransferPartHeight;
UiShared.DrawWithID("group-user-popup", () => _selectPairsForGroupUi.Draw(_pairManager.DirectPairs, ShowUidForEntry));
UiShared.DrawWithID("grouping-popup", () => _selectGroupForPairUi.Draw(ShowUidForEntry));
UiSharedService.DrawWithID("group-user-popup", () => _selectPairsForGroupUi.Draw(_pairManager.DirectPairs, ShowUidForEntry));
UiSharedService.DrawWithID("grouping-popup", () => _selectGroupForPairUi.Draw(ShowUidForEntry));
}
if (_configService.Current.OpenPopupOnAdd && _pairManager.LastAddedUser != null)
@@ -187,7 +177,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
_lastAddedUserComment = string.Empty;
}
if (ImGui.BeginPopupModal("Set Notes for New User", ref _showModalForUserAddition, UiShared.PopupWindowFlags))
if (ImGui.BeginPopupModal("Set Notes for New User", ref _showModalForUserAddition, UiSharedService.PopupWindowFlags))
{
if (_lastAddedUser == null)
{
@@ -195,9 +185,9 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
}
else
{
UiShared.TextWrapped($"You have successfully added {_lastAddedUser.UserData.AliasOrUID}. Set a local note for the user in the field below:");
UiSharedService.TextWrapped($"You have successfully added {_lastAddedUser.UserData.AliasOrUID}. Set a local note for the user in the field below:");
ImGui.InputTextWithHint("##noteforuser", $"Note for {_lastAddedUser.UserData.AliasOrUID}", ref _lastAddedUserComment, 100);
if (UiShared.IconTextButton(FontAwesomeIcon.Save, "Save Note"))
if (UiSharedService.IconTextButton(FontAwesomeIcon.Save, "Save Note"))
{
_serverManager.SetNoteForUid(_lastAddedUser.UserData.UID, _lastAddedUserComment);
_lastAddedUser = null;
@@ -205,7 +195,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
_showModalForUserAddition = false;
}
}
UiShared.SetScaledWindowSize(275);
UiSharedService.SetScaledWindowSize(275);
ImGui.EndPopup();
}
}
@@ -217,12 +207,42 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
base.OnClose();
}
private void DrawAddCharacter()
{
ImGui.Dummy(new(10));
var keys = _serverManager.CurrentServer!.SecretKeys;
if (keys.TryGetValue(_secretKeyIdx, out var secretKey))
{
var friendlyName = secretKey.FriendlyName;
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Add current character with secret key"))
{
_serverManager.CurrentServer!.Authentications.Add(new MareConfiguration.Models.Authentication()
{
CharacterName = _uiShared.PlayerName,
WorldId = _uiShared.WorldId,
SecretKeyIdx = _secretKeyIdx
});
_serverManager.Save();
_ = _apiController.CreateConnections(forceGetToken: true);
}
_uiShared.DrawCombo("Secret Key##addCharacterSecretKey", keys, (f) => f.Value.FriendlyName, (f) => _secretKeyIdx = f.Key);
}
else
{
UiSharedService.ColorTextWrapped("No secret keys are configured for the current server.", ImGuiColors.DalamudYellow);
}
}
private void DrawAddPair()
{
var buttonSize = UiShared.GetIconButtonSize(FontAwesomeIcon.Plus);
ImGui.SetNextItemWidth(UiShared.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X - buttonSize.X);
var buttonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Plus);
ImGui.SetNextItemWidth(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X - buttonSize.X);
ImGui.InputTextWithHint("##otheruid", "Other players UID/Alias", ref _pairToAdd, 20);
ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiShared.GetWindowContentRegionWidth() - buttonSize.X);
ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - buttonSize.X);
var canAdd = !_pairManager.DirectPairs.Any(p => string.Equals(p.UserData.UID, _pairToAdd, StringComparison.Ordinal) || string.Equals(p.UserData.Alias, _pairToAdd, StringComparison.Ordinal));
if (!canAdd)
{
@@ -235,7 +255,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
_ = _apiController.UserAddPair(new(new(_pairToAdd)));
_pairToAdd = string.Empty;
}
UiShared.AttachToolTip("Pair with " + (_pairToAdd.IsNullOrEmpty() ? "other user" : _pairToAdd));
UiSharedService.AttachToolTip("Pair with " + (_pairToAdd.IsNullOrEmpty() ? "other user" : _pairToAdd));
}
ImGuiHelpers.ScaledDummy(2);
@@ -243,8 +263,8 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
private void DrawFilter()
{
var buttonSize = UiShared.GetIconButtonSize(FontAwesomeIcon.ArrowUp);
var playButtonSize = UiShared.GetIconButtonSize(FontAwesomeIcon.Play);
var buttonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.ArrowUp);
var playButtonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Play);
if (!_configService.Current.ReverseUserSort)
{
if (ImGuiComponents.IconButton(FontAwesomeIcon.ArrowDown))
@@ -252,7 +272,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
_configService.Current.ReverseUserSort = true;
_configService.Save();
}
UiShared.AttachToolTip("Sort by name descending");
UiSharedService.AttachToolTip("Sort by name descending");
}
else
{
@@ -261,7 +281,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
_configService.Current.ReverseUserSort = false;
_configService.Save();
}
UiShared.AttachToolTip("Sort by name ascending");
UiSharedService.AttachToolTip("Sort by name ascending");
}
ImGui.SameLine();
@@ -288,12 +308,15 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
case true when !pausedUsers.Any():
_buttonState = false;
break;
case false when !resumedUsers.Any():
_buttonState = true;
break;
case true:
users = pausedUsers;
break;
case false:
users = resumedUsers;
break;
@@ -305,28 +328,25 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
{
_timeout.Reset();
if (ImGuiComponents.IconButton(button))
if (ImGuiComponents.IconButton(button) && UiSharedService.CtrlPressed())
{
if (UiShared.CtrlPressed())
foreach (var entry in users)
{
foreach (var entry in users)
{
var perm = entry.UserPair!.OwnPermissions;
perm.SetPaused(!perm.IsPaused());
_ = _apiController.UserSetPairPermissions(new UserPermissionsDto(entry.UserData, perm));
}
_timeout.Start();
_buttonState = !_buttonState;
var perm = entry.UserPair!.OwnPermissions;
perm.SetPaused(!perm.IsPaused());
_ = _apiController.UserSetPairPermissions(new UserPermissionsDto(entry.UserData, perm));
}
_timeout.Start();
_buttonState = !_buttonState;
}
UiShared.AttachToolTip($"Hold Control to {(button == FontAwesomeIcon.Play ? "resume" : "pause")} pairing with {users.Count} out of {userCount} displayed users.");
UiSharedService.AttachToolTip($"Hold Control to {(button == FontAwesomeIcon.Play ? "resume" : "pause")} pairing with {users.Count} out of {userCount} displayed users.");
}
else
{
var availableAt = (15000 - _timeout.ElapsedMilliseconds) / 1000;
ImGuiComponents.DisabledButton(button);
UiShared.AttachToolTip($"Next execution is available at {availableAt} seconds");
UiSharedService.AttachToolTip($"Next execution is available at {availableAt} seconds");
}
}
@@ -335,14 +355,14 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
if (entry.UserPair == null) return;
var pauseIcon = entry.UserPair!.OwnPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
var pauseIconSize = UiShared.GetIconButtonSize(pauseIcon);
var barButtonSize = UiShared.GetIconButtonSize(FontAwesomeIcon.Bars);
var pauseIconSize = UiSharedService.GetIconButtonSize(pauseIcon);
var barButtonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars);
var entryUID = entry.UserData.AliasOrUID;
var textSize = ImGui.CalcTextSize(entryUID);
var originalY = ImGui.GetCursorPosY();
var buttonSizes = pauseIconSize.Y + barButtonSize.Y;
var spacingX = ImGui.GetStyle().ItemSpacing.X;
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiShared.GetWindowContentRegionWidth();
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
var textPos = originalY + pauseIconSize.Y / 2 - textSize.Y / 2;
ImGui.SetCursorPosY(textPos);
@@ -369,17 +389,17 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
}
ImGui.PushFont(UiBuilder.IconFont);
UiShared.ColorText(connectionIcon.ToIconString(), connectionColor);
UiSharedService.ColorText(connectionIcon.ToIconString(), connectionColor);
ImGui.PopFont();
UiShared.AttachToolTip(connectionText);
UiSharedService.AttachToolTip(connectionText);
ImGui.SameLine();
ImGui.SetCursorPosY(textPos);
if (entry is { IsOnline: true, IsVisible: true })
{
ImGui.PushFont(UiBuilder.IconFont);
UiShared.ColorText(FontAwesomeIcon.Eye.ToIconString(), ImGuiColors.ParsedGreen);
UiSharedService.ColorText(FontAwesomeIcon.Eye.ToIconString(), ImGuiColors.ParsedGreen);
ImGui.PopFont();
UiShared.AttachToolTip(entryUID + " is visible: " + entry.PlayerName!);
UiSharedService.AttachToolTip(entryUID + " is visible: " + entry.PlayerName!);
}
var textIsUid = true;
@@ -414,7 +434,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
if (textIsUid) ImGui.PushFont(UiBuilder.MonoFont);
ImGui.TextUnformatted(playerText);
if (textIsUid) ImGui.PopFont();
UiShared.AttachToolTip("Left click to switch between UID display and nick" + Environment.NewLine +
UiSharedService.AttachToolTip("Left click to switch between UID display and nick" + Environment.NewLine +
"Right click to change nick for " + entryUID);
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
{
@@ -429,7 +449,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
var pair = _pairManager.DirectPairs.Find(p => p.UserData.UID == EditNickEntry);
var pair = _pairManager.DirectPairs.Find(p => string.Equals(p.UserData.UID, EditNickEntry, StringComparison.Ordinal));
if (pair != null)
{
pair.SetNote(EditUserComment);
@@ -443,7 +463,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
{
ImGui.SetCursorPosY(originalY);
ImGui.SetNextItemWidth(UiShared.GetWindowContentRegionWidth() - ImGui.GetCursorPosX() - buttonSizes - ImGui.GetStyle().ItemSpacing.X * 2);
ImGui.SetNextItemWidth(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetCursorPosX() - buttonSizes - ImGui.GetStyle().ItemSpacing.X * 2);
if (ImGui.InputTextWithHint("", "Nick/Notes", ref EditUserComment, 255, ImGuiInputTextFlags.EnterReturnsTrue))
{
_serverManager.SetNoteForUid(entry.UserPair!.User.UID, EditUserComment);
@@ -454,12 +474,58 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
{
EditNickEntry = string.Empty;
}
UiShared.AttachToolTip("Hit ENTER to save\nRight click to cancel");
UiSharedService.AttachToolTip("Hit ENTER to save\nRight click to cancel");
}
// Pause Button
// Pause Button && sound warnings
if (entry.UserPair!.OwnPermissions.IsPaired() && entry.UserPair!.OtherPermissions.IsPaired())
{
var individualSoundsDisabled = (entry.UserPair?.OwnPermissions.IsDisableSounds() ?? false) || (entry.UserPair?.OtherPermissions.IsDisableSounds() ?? false);
var individualAnimDisabled = (entry.UserPair?.OwnPermissions.IsDisableAnimations() ?? false) || (entry.UserPair?.OtherPermissions.IsDisableAnimations() ?? false);
if (individualAnimDisabled || individualSoundsDisabled)
{
var infoIconPosDist = windowEndX - barButtonSize.X - spacingX - pauseIconSize.X - spacingX;
var icon = FontAwesomeIcon.ExclamationTriangle;
var iconwidth = UiSharedService.GetIconSize(icon);
ImGui.SameLine(infoIconPosDist - iconwidth.X);
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
UiSharedService.FontText(icon.ToIconString(), UiBuilder.IconFont);
ImGui.PopStyleColor();
if (ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
ImGui.Text("Individual User permissions");
if (individualSoundsDisabled)
{
var userSoundsText = "Sound sync disabled with " + entry.UserData.AliasOrUID;
UiSharedService.FontText(FontAwesomeIcon.VolumeOff.ToIconString(), UiBuilder.IconFont);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(userSoundsText);
ImGui.NewLine();
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text("You: " + (entry.UserPair!.OwnPermissions.IsDisableSounds() ? "Disabled" : "Enabled") + ", They: " + (entry.UserPair!.OtherPermissions.IsDisableSounds() ? "Disabled" : "Enabled"));
}
if (individualAnimDisabled)
{
var userAnimText = "Animation sync disabled with " + entry.UserData.AliasOrUID;
UiSharedService.FontText(FontAwesomeIcon.Stop.ToIconString(), UiBuilder.IconFont);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text(userAnimText);
ImGui.NewLine();
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.Text("You: " + (entry.UserPair!.OwnPermissions.IsDisableAnimations() ? "Disabled" : "Enabled") + ", They: " + (entry.UserPair!.OtherPermissions.IsDisableAnimations() ? "Disabled" : "Enabled"));
}
ImGui.EndTooltip();
}
}
ImGui.SameLine(windowEndX - barButtonSize.X - spacingX - pauseIconSize.X);
ImGui.SetCursorPosY(originalY);
if (ImGuiComponents.IconButton(pauseIcon))
@@ -468,7 +534,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
perm.SetPaused(!perm.IsPaused());
_ = _apiController.UserSetPairPermissions(new(entry.UserData, perm));
}
UiShared.AttachToolTip(!entry.UserPair!.OwnPermissions.IsPaused()
UiSharedService.AttachToolTip(!entry.UserPair!.OwnPermissions.IsPaused()
? "Pause pairing with " + entryUID
: "Resume pairing with " + entryUID);
}
@@ -483,7 +549,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
}
if (ImGui.BeginPopup("User Flyout Menu"))
{
UiShared.DrawWithID($"buttons-{entry.UserPair!.User.UID}", () => DrawPairedClientMenu(entry));
UiSharedService.DrawWithID($"buttons-{entry.UserPair!.User.UID}", () => DrawPairedClientMenu(entry));
ImGui.EndPopup();
}
}
@@ -492,37 +558,54 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
{
if (entry.IsVisible)
{
if (UiShared.IconTextButton(FontAwesomeIcon.Sync, "Reload last data"))
if (UiSharedService.IconTextButton(FontAwesomeIcon.Sync, "Reload last data"))
{
entry.ApplyLastReceivedData(forced: true);
ImGui.CloseCurrentPopup();
}
UiShared.AttachToolTip("This reapplies the last received character data to this character");
UiSharedService.AttachToolTip("This reapplies the last received character data to this character");
}
var entryUID = entry.UserData.AliasOrUID;
if (UiShared.IconTextButton(FontAwesomeIcon.Folder, "Pair Groups"))
if (UiSharedService.IconTextButton(FontAwesomeIcon.Folder, "Pair Groups"))
{
_selectGroupForPairUi.Open(entry);
}
UiShared.AttachToolTip("Choose pair groups for " + entryUID);
UiSharedService.AttachToolTip("Choose pair groups for " + entryUID);
if (UiShared.IconTextButton(FontAwesomeIcon.Trash, "Unpair Permanently"))
var isDisableSounds = entry.UserPair!.OwnPermissions.IsDisableSounds();
string disableSoundsText = isDisableSounds ? "Enable sound sync" : "Disable sound sync";
var disableSoundsIcon = isDisableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeMute;
if (UiSharedService.IconTextButton(disableSoundsIcon, disableSoundsText))
{
if (UiShared.CtrlPressed())
{
_ = _apiController.UserRemovePair(new(entry.UserData));
}
var permissions = entry.UserPair.OwnPermissions;
permissions.SetDisableSounds(!isDisableSounds);
_ = _apiController.UserSetPairPermissions(new UserPermissionsDto(entry.UserData, permissions));
}
UiShared.AttachToolTip("Hold CTRL and click to unpair permanently from " + entryUID);
var isDisableAnims = entry.UserPair!.OwnPermissions.IsDisableAnimations();
string disableAnimsText = isDisableAnims ? "Enable animation sync" : "Disable animation sync";
var disableAnimsIcon = isDisableAnims ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop;
if (UiSharedService.IconTextButton(disableAnimsIcon, disableAnimsText))
{
var permissions = entry.UserPair.OwnPermissions;
permissions.SetDisableAnimations(!isDisableAnims);
_ = _apiController.UserSetPairPermissions(new UserPermissionsDto(entry.UserData, permissions));
}
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Unpair Permanently") && UiSharedService.CtrlPressed())
{
_ = _apiController.UserRemovePair(new(entry.UserData));
}
UiSharedService.AttachToolTip("Hold CTRL and click to unpair permanently from " + entryUID);
}
private void DrawPairList()
{
UiShared.DrawWithID("addpair", DrawAddPair);
UiShared.DrawWithID("pairs", DrawPairs);
UiSharedService.DrawWithID("addpair", DrawAddPair);
UiSharedService.DrawWithID("pairs", DrawPairs);
TransferPartHeight = ImGui.GetCursorPosY();
UiShared.DrawWithID("filter", DrawFilter);
UiSharedService.DrawWithID("filter", DrawFilter);
}
private void DrawPairs()
@@ -552,20 +635,9 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
ImGui.EndChild();
}
private List<Pair> GetFilteredUsers()
{
return _pairManager.DirectPairs.Where(p =>
{
if (_characterOrCommentFilter.IsNullOrEmpty()) return true;
return p.UserData.AliasOrUID.Contains(_characterOrCommentFilter, StringComparison.OrdinalIgnoreCase) ||
(p.GetNote()?.Contains(_characterOrCommentFilter, StringComparison.OrdinalIgnoreCase) ?? false) ||
(p.PlayerName?.Contains(_characterOrCommentFilter) ?? false);
}).ToList();
}
private void DrawServerStatus()
{
var buttonSize = UiShared.GetIconButtonSize(FontAwesomeIcon.Link);
var buttonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Link);
var userCount = _apiController.OnlineUsers.ToString(CultureInfo.InvariantCulture);
var userSize = ImGui.CalcTextSize(userCount);
var textSize = ImGui.CalcTextSize("Users Online");
@@ -579,7 +651,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
if (_apiController.ServerState is ServerState.Connected)
{
ImGui.SetCursorPosX((ImGui.GetWindowContentRegionMin().X + UiShared.GetWindowContentRegionWidth() - buttonSize.X) / 2 - (userSize.X + textSize.X) / 2 - ImGui.GetStyle().ItemSpacing.X / 2);
ImGui.SetCursorPosX((ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - buttonSize.X) / 2 - (userSize.X + textSize.X) / 2 - ImGui.GetStyle().ItemSpacing.X / 2);
if (!printShard) ImGui.AlignTextToFramePadding();
ImGui.TextColored(ImGuiColors.ParsedGreen, userCount);
ImGui.SameLine();
@@ -595,16 +667,16 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
if (printShard)
{
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - ImGui.GetStyle().ItemSpacing.Y);
ImGui.SetCursorPosX((ImGui.GetWindowContentRegionMin().X + UiShared.GetWindowContentRegionWidth() - buttonSize.X) / 2 - shardTextSize.X / 2);
ImGui.SetCursorPosX((ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - buttonSize.X) / 2 - shardTextSize.X / 2);
ImGui.TextUnformatted(shardConnection);
}
ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiShared.GetWindowContentRegionWidth() - buttonSize.X);
ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - buttonSize.X);
if (printShard)
{
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - ((userSize.Y + textSize.Y) / 2 + shardTextSize.Y) / 2 - ImGui.GetStyle().ItemSpacing.Y + buttonSize.Y / 2);
}
var color = UiShared.GetBoolColor(!_serverManager.CurrentServer!.FullPause);
var color = UiSharedService.GetBoolColor(!_serverManager.CurrentServer!.FullPause);
var connectedIcon = !_serverManager.CurrentServer.FullPause ? FontAwesomeIcon.Link : FontAwesomeIcon.Unlink;
if (_apiController.ServerState != ServerState.Reconnecting)
@@ -617,13 +689,13 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
_ = _apiController.CreateConnections();
}
ImGui.PopStyleColor();
UiShared.AttachToolTip(!_serverManager.CurrentServer.FullPause ? "Disconnect from " + _serverManager.CurrentServer.ServerName : "Connect to " + _serverManager.CurrentServer.ServerName);
UiSharedService.AttachToolTip(!_serverManager.CurrentServer.FullPause ? "Disconnect from " + _serverManager.CurrentServer.ServerName : "Connect to " + _serverManager.CurrentServer.ServerName);
}
}
private void DrawTransfers()
{
var currentUploads = _apiController.CurrentUploads.ToList();
var currentUploads = _fileTransferManager.CurrentUploads.ToList();
ImGui.PushFont(UiBuilder.IconFont);
ImGui.Text(FontAwesomeIcon.Upload.ToIconString());
ImGui.PopFont();
@@ -638,7 +710,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
var totalToUpload = currentUploads.Sum(c => c.Total);
ImGui.Text($"{doneUploads}/{totalUploads}");
var uploadText = $"({UiShared.ByteToString(totalUploaded)}/{UiShared.ByteToString(totalToUpload)})";
var uploadText = $"({UiSharedService.ByteToString(totalUploaded)}/{UiSharedService.ByteToString(totalToUpload)})";
var textSize = ImGui.CalcTextSize(uploadText);
ImGui.SameLine(WindowContentWidth - textSize.X);
ImGui.Text(uploadText);
@@ -648,7 +720,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
ImGui.Text("No uploads in progress");
}
var currentDownloads = _apiController.CurrentDownloads.SelectMany(k => k.Value).ToList();
var currentDownloads = _currentDownloads.SelectMany(d => d.Value.Values).ToList();
ImGui.PushFont(UiBuilder.IconFont);
ImGui.Text(FontAwesomeIcon.Download.ToIconString());
ImGui.PopFont();
@@ -656,14 +728,14 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
if (currentDownloads.Any())
{
var totalDownloads = currentDownloads.Count();
var doneDownloads = currentDownloads.Count(c => c.IsTransferred);
var totalDownloaded = currentDownloads.Sum(c => c.Transferred);
var totalToDownload = currentDownloads.Sum(c => c.Total);
var totalDownloads = currentDownloads.Sum(c => c.TotalFiles);
var doneDownloads = currentDownloads.Sum(c => c.TransferredFiles);
var totalDownloaded = currentDownloads.Sum(c => c.TransferredBytes);
var totalToDownload = currentDownloads.Sum(c => c.TotalBytes);
ImGui.Text($"{doneDownloads}/{totalDownloads}");
var downloadText =
$"({UiShared.ByteToString(totalDownloaded)}/{UiShared.ByteToString(totalToDownload)})";
$"({UiSharedService.ByteToString(totalDownloaded)}/{UiSharedService.ByteToString(totalToDownload)})";
var textSize = ImGui.CalcTextSize(downloadText);
ImGui.SameLine(WindowContentWidth - textSize.X);
ImGui.Text(downloadText);
@@ -687,28 +759,28 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
var originalPos = ImGui.GetCursorPos();
ImGui.SetWindowFontScale(1.5f);
var buttonSize = UiShared.GetIconButtonSize(FontAwesomeIcon.Cog);
var buttonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Cog);
buttonSizeX -= buttonSize.X - ImGui.GetStyle().ItemSpacing.X * 2;
ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiShared.GetWindowContentRegionWidth() - buttonSize.X);
ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - buttonSize.X);
ImGui.SetCursorPosY(originalPos.Y + uidTextSize.Y / 2 - buttonSize.Y / 2);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Cog))
{
Mediator.Publish(new OpenSettingsUiMessage());
}
UiShared.AttachToolTip("Open the Mare Synchronos Settings");
UiSharedService.AttachToolTip("Open the Mare Synchronos Settings");
ImGui.SameLine(); //Important to draw the uidText consistently
ImGui.SetCursorPos(originalPos);
if (_apiController.ServerState is ServerState.Connected)
{
buttonSizeX += UiShared.GetIconButtonSize(FontAwesomeIcon.Copy).X - ImGui.GetStyle().ItemSpacing.X * 2;
buttonSizeX += UiSharedService.GetIconButtonSize(FontAwesomeIcon.Copy).X - ImGui.GetStyle().ItemSpacing.X * 2;
ImGui.SetCursorPosY(originalPos.Y + uidTextSize.Y / 2 - buttonSize.Y / 2);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Copy))
{
ImGui.SetClipboardText(_apiController.DisplayName);
}
UiShared.AttachToolTip("Copy your UID to clipboard");
UiSharedService.AttachToolTip("Copy your UID to clipboard");
ImGui.SameLine();
}
ImGui.SetWindowFontScale(1f);
@@ -721,7 +793,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
if (_apiController.ServerState is not ServerState.Connected)
{
UiShared.ColorTextWrapped(GetServerError(), GetUidColor());
UiSharedService.ColorTextWrapped(GetServerError(), GetUidColor());
if (_apiController.ServerState is ServerState.NoSecretKey)
{
DrawAddCharacter();
@@ -729,38 +801,17 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
}
}
private void DrawAddCharacter()
private List<Pair> GetFilteredUsers()
{
ImGui.Dummy(new(10));
var keys = _serverManager.CurrentServer!.SecretKeys;
if (keys.TryGetValue(secretKeyIdx, out var secretKey))
return _pairManager.DirectPairs.Where(p =>
{
var friendlyName = secretKey.FriendlyName;
if (UiShared.IconTextButton(FontAwesomeIcon.Plus, "Add current character with secret key"))
{
_serverManager.CurrentServer!.Authentications.Add(new MareConfiguration.Models.Authentication()
{
CharacterName = _uiShared.PlayerName,
WorldId = _uiShared.WorldId,
SecretKeyIdx = secretKeyIdx
});
_serverManager.Save();
_ = _apiController.CreateConnections(forceGetToken: true);
}
_uiShared.DrawCombo("Secret Key##addCharacterSecretKey", keys, (f) => f.Value.FriendlyName, (f) => secretKeyIdx = f.Key);
}
else
{
UiShared.ColorTextWrapped("No secret keys are configured for the current server.", ImGuiColors.DalamudYellow);
}
if (_characterOrCommentFilter.IsNullOrEmpty()) return true;
return p.UserData.AliasOrUID.Contains(_characterOrCommentFilter, StringComparison.OrdinalIgnoreCase) ||
(p.GetNote()?.Contains(_characterOrCommentFilter, StringComparison.OrdinalIgnoreCase) ?? false) ||
(p.PlayerName?.Contains(_characterOrCommentFilter, StringComparison.OrdinalIgnoreCase) ?? false);
}).ToList();
}
private int secretKeyIdx = 0;
private string GetServerError()
{
return _apiController.ServerState switch
@@ -812,4 +863,15 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
_ => string.Empty
};
}
}
private void UiSharedService_GposeEnd()
{
IsOpen = _wasOpen;
}
private void UiSharedService_GposeStart()
{
_wasOpen = IsOpen;
IsOpen = false;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -2,215 +2,236 @@
using Dalamud.Interface.Components;
using ImGuiNET;
using MareSynchronos.API.Data.Extensions;
using MareSynchronos.Models;
using MareSynchronos.MareConfiguration;
using MareSynchronos.PlayerData.Pairs;
using MareSynchronos.UI.Handlers;
using MareSynchronos.WebAPI;
namespace MareSynchronos.UI.Components
namespace MareSynchronos.UI.Components;
public class PairGroupsUi
{
public class PairGroupsUi
private readonly ApiController _apiController;
private readonly Action<Pair> _clientRenderFn;
private readonly MareConfigService _mareConfig;
private readonly SelectPairForGroupUi _selectGroupForPairUi;
private readonly TagHandler _tagHandler;
public PairGroupsUi(MareConfigService mareConfig, TagHandler tagHandler, Action<Pair> clientRenderFn, ApiController apiController, SelectPairForGroupUi selectGroupForPairUi)
{
private readonly Action<Pair> _clientRenderFn;
private readonly TagHandler _tagHandler;
private readonly ApiController _apiController;
private readonly SelectPairForGroupUi _selectGroupForPairUi;
_clientRenderFn = clientRenderFn;
_mareConfig = mareConfig;
_tagHandler = tagHandler;
_apiController = apiController;
_selectGroupForPairUi = selectGroupForPairUi;
}
public PairGroupsUi(TagHandler tagHandler, Action<Pair> clientRenderFn, ApiController apiController, SelectPairForGroupUi selectGroupForPairUi)
public void Draw(List<Pair> visibleUsers, List<Pair> onlineUsers, List<Pair> offlineUsers)
{
// Only render those tags that actually have pairs in them, otherwise
// we can end up with a bunch of useless pair groups
var tagsWithPairsInThem = _tagHandler.GetAllTagsSorted();
var allUsers = visibleUsers.Concat(onlineUsers).Concat(offlineUsers).ToList();
if (_mareConfig.Current.ShowVisibleUsersSeparately)
{
_clientRenderFn = clientRenderFn;
_tagHandler = tagHandler;
_apiController = apiController;
_selectGroupForPairUi = selectGroupForPairUi;
UiSharedService.DrawWithID("$group-VisibleCustomTag", () => DrawCategory(TagHandler.CustomVisibleTag, visibleUsers, allUsers));
}
public void Draw(List<Pair> visibleUsers, List<Pair> onlineUsers, List<Pair> offlineUsers)
foreach (var tag in tagsWithPairsInThem)
{
// Only render those tags that actually have pairs in them, otherwise
// we can end up with a bunch of useless pair groups
var tagsWithPairsInThem = _tagHandler.GetAllTagsSorted();
var allUsers = visibleUsers.Concat(onlineUsers).Concat(offlineUsers).ToList();
UiShared.DrawWithID("$group-VisibleCustomTag", () => DrawCategory(TagHandler.CustomVisibleTag, visibleUsers, allUsers));
foreach (var tag in tagsWithPairsInThem)
if (_mareConfig.Current.ShowOfflineUsersSeparately)
{
UiShared.DrawWithID($"group-{tag}", () => DrawCategory(tag, onlineUsers, allUsers, visibleUsers));
}
UiShared.DrawWithID($"group-OnlineCustomTag", () => DrawCategory(TagHandler.CustomOnlineTag, onlineUsers.Where(u => !_tagHandler.HasAnyTag(u.UserPair!)).ToList(), allUsers));
UiShared.DrawWithID($"group-OfflineCustomTag", () => DrawCategory(TagHandler.CustomOfflineTag, offlineUsers, allUsers));
}
private void DrawCategory(string tag, List<Pair> onlineUsers, List<Pair> allUsers, List<Pair>? visibleUsers = null)
{
List<Pair> usersInThisTag;
HashSet<string>? otherUidsTaggedWithTag = null;
bool isSpecialTag = false;
int visibleInThisTag = 0;
if (tag is TagHandler.CustomOfflineTag or TagHandler.CustomOnlineTag or TagHandler.CustomVisibleTag)
{
usersInThisTag = onlineUsers;
isSpecialTag = true;
UiSharedService.DrawWithID($"group-{tag}", () => DrawCategory(tag, onlineUsers, allUsers, visibleUsers));
}
else
{
otherUidsTaggedWithTag = _tagHandler.GetOtherUidsForTag(tag);
usersInThisTag = onlineUsers
.Where(pair => otherUidsTaggedWithTag.Contains(pair.UserData.UID))
.ToList();
visibleInThisTag = visibleUsers?.Count(p => otherUidsTaggedWithTag.Contains(p.UserData.UID)) ?? 0;
}
if (isSpecialTag && !usersInThisTag.Any()) return;
DrawName(tag, isSpecialTag, visibleInThisTag, usersInThisTag.Count, otherUidsTaggedWithTag?.Count);
if (!isSpecialTag)
UiShared.DrawWithID($"group-{tag}-buttons", () => DrawButtons(tag, allUsers.Where(p => otherUidsTaggedWithTag!.Contains(p.UserData.UID)).ToList()));
if (!_tagHandler.IsTagOpen(tag)) return;
ImGui.Indent(20);
DrawPairs(tag, usersInThisTag);
ImGui.Unindent(20);
}
private void DrawName(string tag, bool isSpecialTag, int visible, int online, int? total)
{
string displayedName = tag switch
{
TagHandler.CustomOfflineTag => "Offline/Unpaired",
TagHandler.CustomOnlineTag => "Online/Paused",
TagHandler.CustomVisibleTag => "Visible",
_ => tag
};
string resultFolderName = !isSpecialTag ? $"{displayedName} ({visible}/{online}/{total} Pairs)" : $"{displayedName} ({online} Pairs)";
// FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight
var icon = _tagHandler.IsTagOpen(tag) ? FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight;
UiShared.FontText(icon.ToIconString(), UiBuilder.IconFont);
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
{
ToggleTagOpen(tag);
}
ImGui.SameLine();
UiShared.FontText(resultFolderName, UiBuilder.DefaultFont);
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
{
ToggleTagOpen(tag);
}
if (!isSpecialTag && ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
ImGui.TextUnformatted($"Group {tag}");
ImGui.Separator();
ImGui.TextUnformatted($"{visible} Pairs visible");
ImGui.TextUnformatted($"{online} Pairs online/paused");
ImGui.TextUnformatted($"{total} Pairs total");
ImGui.EndTooltip();
UiSharedService.DrawWithID($"group-{tag}", () => DrawCategory(tag, onlineUsers.Concat(offlineUsers).ToList(), allUsers, visibleUsers));
}
}
private void DrawButtons(string tag, List<Pair> availablePairsInThisTag)
if (_mareConfig.Current.ShowOfflineUsersSeparately)
{
var allArePaused = availablePairsInThisTag.All(pair => pair.UserPair!.OwnPermissions.IsPaused());
var pauseButton = allArePaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
var flyoutMenuX = UiShared.GetIconButtonSize(FontAwesomeIcon.Bars).X;
var pauseButtonX = UiShared.GetIconButtonSize(pauseButton).X;
var windowX = ImGui.GetWindowContentRegionMin().X;
var windowWidth = UiShared.GetWindowContentRegionWidth();
var spacingX = ImGui.GetStyle().ItemSpacing.X;
UiSharedService.DrawWithID($"group-OnlineCustomTag", () => DrawCategory(TagHandler.CustomOnlineTag,
onlineUsers.Where(u => !_tagHandler.HasAnyTag(u.UserPair!)).ToList(), allUsers));
UiSharedService.DrawWithID($"group-OfflineCustomTag", () => DrawCategory(TagHandler.CustomOfflineTag,
offlineUsers.Where(u => u.UserPair!.OtherPermissions.IsPaired()).ToList(), allUsers));
}
else
{
UiSharedService.DrawWithID($"group-OnlineCustomTag", () => DrawCategory(TagHandler.CustomOnlineTag,
onlineUsers.Concat(offlineUsers).Where(u => u.UserPair!.OtherPermissions.IsPaired() && !_tagHandler.HasAnyTag(u.UserPair!)).ToList(), allUsers));
}
UiSharedService.DrawWithID($"group-UnpairedCustomTag", () => DrawCategory(TagHandler.CustomUnpairedTag,
offlineUsers.Where(u => !u.UserPair!.OtherPermissions.IsPaired()).ToList(), allUsers));
}
var buttonPauseOffset = windowX + windowWidth - flyoutMenuX - spacingX - pauseButtonX;
ImGui.SameLine(buttonPauseOffset);
if (ImGuiComponents.IconButton(pauseButton))
{
// If all of the currently visible pairs (after applying filters to the pairs)
// are paused we display a resume button to resume all currently visible (after filters)
// pairs. Otherwise, we just pause all the remaining pairs.
if (allArePaused)
{
// If all are paused => resume all
ResumeAllPairs(availablePairsInThisTag);
}
else
{
// otherwise pause all remaining
PauseRemainingPairs(availablePairsInThisTag);
}
}
private void DrawButtons(string tag, List<Pair> availablePairsInThisTag)
{
var allArePaused = availablePairsInThisTag.All(pair => pair.UserPair!.OwnPermissions.IsPaused());
var pauseButton = allArePaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
var flyoutMenuX = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars).X;
var pauseButtonX = UiSharedService.GetIconButtonSize(pauseButton).X;
var windowX = ImGui.GetWindowContentRegionMin().X;
var windowWidth = UiSharedService.GetWindowContentRegionWidth();
var spacingX = ImGui.GetStyle().ItemSpacing.X;
var buttonPauseOffset = windowX + windowWidth - flyoutMenuX - spacingX - pauseButtonX;
ImGui.SameLine(buttonPauseOffset);
if (ImGuiComponents.IconButton(pauseButton))
{
// If all of the currently visible pairs (after applying filters to the pairs)
// are paused we display a resume button to resume all currently visible (after filters)
// pairs. Otherwise, we just pause all the remaining pairs.
if (allArePaused)
{
UiShared.AttachToolTip($"Resume pairing with all pairs in {tag}");
// If all are paused => resume all
ResumeAllPairs(availablePairsInThisTag);
}
else
{
UiShared.AttachToolTip($"Pause pairing with all pairs in {tag}");
}
var buttonDeleteOffset = windowX + windowWidth - flyoutMenuX;
ImGui.SameLine(buttonDeleteOffset);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Bars))
{
ImGui.OpenPopup("Group Flyout Menu");
}
if (ImGui.BeginPopup("Group Flyout Menu"))
{
UiShared.DrawWithID($"buttons-{tag}", () => DrawGroupMenu(tag));
ImGui.EndPopup();
// otherwise pause all remaining
PauseRemainingPairs(availablePairsInThisTag);
}
}
private void DrawGroupMenu(string tag)
if (allArePaused)
{
if (UiShared.IconTextButton(FontAwesomeIcon.Users, "Add people to " + tag))
{
_selectGroupForPairUi.Open(tag);
}
UiShared.AttachToolTip($"Add more users to Group {tag}");
if (UiShared.IconTextButton(FontAwesomeIcon.Trash, "Delete " + tag))
{
if (UiShared.CtrlPressed())
{
_tagHandler.RemoveTag(tag);
}
}
UiShared.AttachToolTip($"Delete Group {tag} (Will not delete the pairs)" + Environment.NewLine + "Hold CTRL to delete");
UiSharedService.AttachToolTip($"Resume pairing with all pairs in {tag}");
}
else
{
UiSharedService.AttachToolTip($"Pause pairing with all pairs in {tag}");
}
private void DrawPairs(string tag, List<Pair> availablePairsInThisCategory)
var buttonDeleteOffset = windowX + windowWidth - flyoutMenuX;
ImGui.SameLine(buttonDeleteOffset);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Bars))
{
// These are all the OtherUIDs that are tagged with this tag
availablePairsInThisCategory
.ForEach(pair => UiShared.DrawWithID($"tag-{tag}-pair-${pair.UserData.UID}", () => _clientRenderFn(pair)));
ImGui.Separator();
ImGui.OpenPopup("Group Flyout Menu");
}
private void ToggleTagOpen(string tag)
if (ImGui.BeginPopup("Group Flyout Menu"))
{
bool open = !_tagHandler.IsTagOpen(tag);
_tagHandler.SetTagOpen(tag, open);
}
private void PauseRemainingPairs(List<Pair> availablePairs)
{
foreach (var pairToPause in availablePairs.Where(pair => !pair.UserPair!.OwnPermissions.IsPaused()))
{
var perm = pairToPause.UserPair!.OwnPermissions;
perm.SetPaused(paused: true);
_ = _apiController.UserSetPairPermissions(new(pairToPause.UserData, perm));
}
}
private void ResumeAllPairs(List<Pair> availablePairs)
{
foreach (var pairToPause in availablePairs)
{
var perm = pairToPause.UserPair!.OwnPermissions;
perm.SetPaused(paused: false);
_ = _apiController.UserSetPairPermissions(new(pairToPause.UserData, perm));
}
UiSharedService.DrawWithID($"buttons-{tag}", () => DrawGroupMenu(tag));
ImGui.EndPopup();
}
}
private void DrawCategory(string tag, List<Pair> onlineUsers, List<Pair> allUsers, List<Pair>? visibleUsers = null)
{
List<Pair> usersInThisTag;
HashSet<string>? otherUidsTaggedWithTag = null;
bool isSpecialTag = false;
int visibleInThisTag = 0;
if (tag is TagHandler.CustomOfflineTag or TagHandler.CustomOnlineTag or TagHandler.CustomVisibleTag or TagHandler.CustomUnpairedTag)
{
usersInThisTag = onlineUsers;
isSpecialTag = true;
}
else
{
otherUidsTaggedWithTag = _tagHandler.GetOtherUidsForTag(tag);
usersInThisTag = onlineUsers
.Where(pair => otherUidsTaggedWithTag.Contains(pair.UserData.UID))
.ToList();
visibleInThisTag = visibleUsers?.Count(p => otherUidsTaggedWithTag.Contains(p.UserData.UID)) ?? 0;
}
if (isSpecialTag && !usersInThisTag.Any()) return;
DrawName(tag, isSpecialTag, visibleInThisTag, usersInThisTag.Count, otherUidsTaggedWithTag?.Count);
if (!isSpecialTag)
UiSharedService.DrawWithID($"group-{tag}-buttons", () => DrawButtons(tag, allUsers.Where(p => otherUidsTaggedWithTag!.Contains(p.UserData.UID)).ToList()));
if (!_tagHandler.IsTagOpen(tag)) return;
ImGui.Indent(20);
DrawPairs(tag, usersInThisTag);
ImGui.Unindent(20);
}
private void DrawGroupMenu(string tag)
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.Users, "Add people to " + tag))
{
_selectGroupForPairUi.Open(tag);
}
UiSharedService.AttachToolTip($"Add more users to Group {tag}");
if (UiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete " + tag) && UiSharedService.CtrlPressed())
{
_tagHandler.RemoveTag(tag);
}
UiSharedService.AttachToolTip($"Delete Group {tag} (Will not delete the pairs)" + Environment.NewLine + "Hold CTRL to delete");
}
private void DrawName(string tag, bool isSpecialTag, int visible, int online, int? total)
{
string displayedName = tag switch
{
TagHandler.CustomUnpairedTag => "Unpaired",
TagHandler.CustomOfflineTag => "Offline",
TagHandler.CustomOnlineTag => _mareConfig.Current.ShowOfflineUsersSeparately ? "Online/Paused" : "Contacts",
TagHandler.CustomVisibleTag => "Visible",
_ => tag
};
string resultFolderName = !isSpecialTag ? $"{displayedName} ({visible}/{online}/{total} Pairs)" : $"{displayedName} ({online} Pairs)";
// FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight
var icon = _tagHandler.IsTagOpen(tag) ? FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight;
UiSharedService.FontText(icon.ToIconString(), UiBuilder.IconFont);
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
{
ToggleTagOpen(tag);
}
ImGui.SameLine();
UiSharedService.FontText(resultFolderName, UiBuilder.DefaultFont);
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
{
ToggleTagOpen(tag);
}
if (!isSpecialTag && ImGui.IsItemHovered())
{
ImGui.BeginTooltip();
ImGui.TextUnformatted($"Group {tag}");
ImGui.Separator();
ImGui.TextUnformatted($"{visible} Pairs visible");
ImGui.TextUnformatted($"{online} Pairs online/paused");
ImGui.TextUnformatted($"{total} Pairs total");
ImGui.EndTooltip();
}
}
private void DrawPairs(string tag, List<Pair> availablePairsInThisCategory)
{
// These are all the OtherUIDs that are tagged with this tag
availablePairsInThisCategory
.ForEach(pair => UiSharedService.DrawWithID($"tag-{tag}-pair-${pair.UserData.UID}", () => _clientRenderFn(pair)));
ImGui.Separator();
}
private void PauseRemainingPairs(List<Pair> availablePairs)
{
foreach (var pairToPause in availablePairs.Where(pair => !pair.UserPair!.OwnPermissions.IsPaused()))
{
var perm = pairToPause.UserPair!.OwnPermissions;
perm.SetPaused(paused: true);
_ = _apiController.UserSetPairPermissions(new(pairToPause.UserData, perm));
}
}
private void ResumeAllPairs(List<Pair> availablePairs)
{
foreach (var pairToPause in availablePairs)
{
var perm = pairToPause.UserPair!.OwnPermissions;
perm.SetPaused(paused: false);
_ = _apiController.UserSetPairPermissions(new(pairToPause.UserData, perm));
}
}
private void ToggleTagOpen(string tag)
{
bool open = !_tagHandler.IsTagOpen(tag);
_tagHandler.SetTagOpen(tag, open);
}
}

View File

@@ -3,17 +3,14 @@ using Dalamud.Interface;
using Dalamud.Interface.Components;
using Dalamud.Utility;
using ImGuiNET;
using MareSynchronos.Models;
using MareSynchronos.PlayerData.Pairs;
using MareSynchronos.UI.Handlers;
namespace MareSynchronos.UI.Components;
public class SelectGroupForPairUi
{
/// <summary>
/// Should the panel show, yes/no
/// </summary>
private bool _show;
private readonly TagHandler _tagHandler;
/// <summary>
/// The group UI is always open for a specific pair. This defines which pair the UI is open for.
@@ -21,13 +18,16 @@ public class SelectGroupForPairUi
/// <returns></returns>
private Pair? _pair;
/// <summary>
/// Should the panel show, yes/no
/// </summary>
private bool _show;
/// <summary>
/// For the add category option, this stores the currently typed in tag name
/// </summary>
private string _tagNameToAdd = "";
private readonly TagHandler _tagHandler;
public SelectGroupForPairUi(TagHandler tagHandler)
{
_show = false;
@@ -35,17 +35,6 @@ public class SelectGroupForPairUi
_tagHandler = tagHandler;
}
public void Open(Pair pair)
{
_pair = pair;
// Using "_show" here to de-couple the opening of the popup
// The popup name is derived from the name the user currently sees, which is
// based on the showUidForEntry dictionary.
// We'd have to derive the name here to open it popup modal here, when the Open() is called
_show = true;
}
public void Draw(Dictionary<string, bool> showUidForEntry)
{
if (_pair == null)
@@ -68,34 +57,53 @@ public class SelectGroupForPairUi
var childHeight = tags.Count != 0 ? tags.Count * 25 : 1;
var childSize = new Vector2(0, childHeight > 100 ? 100 : childHeight) * ImGuiHelpers.GlobalScale;
UiShared.FontText($"Select the groups you want {name} to be in.", UiBuilder.DefaultFont);
UiSharedService.FontText($"Select the groups you want {name} to be in.", UiBuilder.DefaultFont);
if (ImGui.BeginChild(name + "##listGroups", childSize))
{
foreach (var tag in tags)
{
UiShared.DrawWithID($"groups-pair-{_pair.UserData.UID}-{tag}", () => DrawGroupName(_pair, tag));
UiSharedService.DrawWithID($"groups-pair-{_pair.UserData.UID}-{tag}", () => DrawGroupName(_pair, tag));
}
ImGui.EndChild();
}
ImGui.Separator();
UiShared.FontText($"Create a new group for {name}.", UiBuilder.DefaultFont);
UiSharedService.FontText($"Create a new group for {name}.", UiBuilder.DefaultFont);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Plus))
{
HandleAddTag();
}
ImGui.SameLine();
ImGui.InputTextWithHint("##category_name", "New Group", ref _tagNameToAdd, 40);
if (ImGui.IsKeyDown(ImGuiKey.Enter))
{
if (ImGui.IsKeyDown(ImGuiKey.Enter))
{
HandleAddTag();
}
HandleAddTag();
}
ImGui.EndPopup();
}
}
public void Open(Pair pair)
{
_pair = pair;
// Using "_show" here to de-couple the opening of the popup
// The popup name is derived from the name the user currently sees, which is
// based on the showUidForEntry dictionary.
// We'd have to derive the name here to open it popup modal here, when the Open() is called
_show = true;
}
private static string PairName(Dictionary<string, bool> showUidForEntry, Pair pair)
{
showUidForEntry.TryGetValue(pair.UserData.UID, out var showUidInsteadOfName);
var playerText = pair.GetNote();
if (showUidInsteadOfName || string.IsNullOrEmpty(playerText))
{
playerText = pair.UserData.AliasOrUID;
}
return playerText;
}
private void DrawGroupName(Pair pair, string name)
{
var hasTagBefore = _tagHandler.HasTag(pair.UserPair!, name);
@@ -129,15 +137,4 @@ public class SelectGroupForPairUi
_tagNameToAdd = string.Empty;
}
}
private string PairName(Dictionary<string, bool> showUidForEntry, Pair pair)
{
showUidForEntry.TryGetValue(pair.UserData.UID, out var showUidInsteadOfName);
var playerText = pair.GetNote();
if (showUidInsteadOfName || string.IsNullOrEmpty(playerText))
{
playerText = pair.UserData.AliasOrUID;
}
return playerText;
}
}

View File

@@ -1,38 +1,31 @@
using System.Numerics;
using Dalamud.Interface;
using ImGuiNET;
using MareSynchronos.Models;
using MareSynchronos.PlayerData.Pairs;
using MareSynchronos.UI.Handlers;
namespace MareSynchronos.UI.Components;
public class SelectPairForGroupUi
{
private bool _show = false;
private bool _opened = false;
private HashSet<string> _peopleInGroup = new(StringComparer.Ordinal);
private string _tag = string.Empty;
private readonly TagHandler _tagHandler;
private string _filter = string.Empty;
private bool _opened = false;
private HashSet<string> _peopleInGroup = new(StringComparer.Ordinal);
private bool _show = false;
private string _tag = string.Empty;
public SelectPairForGroupUi(TagHandler tagHandler)
{
_tagHandler = tagHandler;
}
public void Open(string tag)
{
_peopleInGroup = _tagHandler.GetOtherUidsForTag(tag);
_tag = tag;
_show = true;
}
public void Draw(List<Pair> pairs, Dictionary<string, bool> showUidForEntry)
{
var workHeight = ImGui.GetMainViewport().WorkSize.Y / ImGuiHelpers.GlobalScale;
var minSize = new Vector2(300, workHeight < 400 ? workHeight : 400) * ImGuiHelpers.GlobalScale;
var maxSize = new Vector2(300, 1000) * ImGuiHelpers.GlobalScale;
var popupName = $"Choose Users for Group {_tag}";
if (!_show)
@@ -43,7 +36,7 @@ public class SelectPairForGroupUi
if (_show && !_opened)
{
ImGui.SetNextWindowSize(minSize);
UiShared.CenterNextWindow(minSize.X, minSize.Y, ImGuiCond.Always);
UiSharedService.CenterNextWindow(minSize.X, minSize.Y, ImGuiCond.Always);
ImGui.OpenPopup(popupName);
_opened = true;
}
@@ -51,10 +44,12 @@ public class SelectPairForGroupUi
ImGui.SetNextWindowSizeConstraints(minSize, maxSize);
if (ImGui.BeginPopupModal(popupName, ref _show, ImGuiWindowFlags.Popup | ImGuiWindowFlags.Modal))
{
UiShared.FontText($"Select users for group {_tag}", UiBuilder.DefaultFont);
UiSharedService.FontText($"Select users for group {_tag}", UiBuilder.DefaultFont);
ImGui.InputTextWithHint("##filter", "Filter", ref _filter, 255, ImGuiInputTextFlags.None);
foreach (var item in pairs.OrderBy(p => PairName(showUidForEntry, p), StringComparer.OrdinalIgnoreCase)
.Where(p => string.IsNullOrEmpty(_filter) || PairName(showUidForEntry, p).Contains(_filter, StringComparison.OrdinalIgnoreCase)).ToList())
foreach (var item in pairs
.Where(p => string.IsNullOrEmpty(_filter) || PairName(showUidForEntry, p).Contains(_filter, StringComparison.OrdinalIgnoreCase))
.OrderBy(p => PairName(showUidForEntry, p), StringComparer.OrdinalIgnoreCase)
.ToList())
{
var isInGroup = _peopleInGroup.Contains(item.UserData.UID);
if (ImGui.Checkbox(PairName(showUidForEntry, item), ref isInGroup))
@@ -80,7 +75,14 @@ public class SelectPairForGroupUi
}
}
private string PairName(Dictionary<string, bool> showUidForEntry, Pair pair)
public void Open(string tag)
{
_peopleInGroup = _tagHandler.GetOtherUidsForTag(tag);
_tag = tag;
_show = true;
}
private static string PairName(Dictionary<string, bool> showUidForEntry, Pair pair)
{
showUidForEntry.TryGetValue(pair.UserData.UID, out var showUidInsteadOfName);
var playerText = pair.GetNote();
@@ -90,4 +92,4 @@ public class SelectPairForGroupUi
}
return playerText;
}
}
}

View File

@@ -1,40 +1,38 @@
using System.Numerics;
using Dalamud.Interface.Windowing;
using Dalamud.Interface.Colors;
using ImGuiNET;
using MareSynchronos.MareConfiguration;
using MareSynchronos.WebAPI;
using MareSynchronos.PlayerData.Handlers;
using MareSynchronos.Services;
using MareSynchronos.Services.Mediator;
using MareSynchronos.WebAPI.Files;
using MareSynchronos.WebAPI.Files.Models;
using Microsoft.Extensions.Logging;
using System.Collections.Concurrent;
using System.Numerics;
namespace MareSynchronos.UI;
public class DownloadUi : Window, IDisposable
public class DownloadUi : WindowMediatorSubscriberBase
{
private readonly ILogger<DownloadUi> _logger;
private readonly WindowSystem _windowSystem;
private readonly MareConfigService _configService;
private readonly ApiController _apiController;
private readonly UiShared _uiShared;
private bool _wasOpen = false;
private readonly ConcurrentDictionary<GameObjectHandler, Dictionary<string, FileDownloadStatus>> _currentDownloads = new();
private readonly DalamudUtilService _dalamudUtilService;
private readonly FileUploadManager _fileTransferManager;
private readonly UiSharedService _uiShared;
private readonly ConcurrentDictionary<GameObjectHandler, bool> _uploadingPlayers = new();
public void Dispose()
public DownloadUi(ILogger<DownloadUi> logger, DalamudUtilService dalamudUtilService, MareConfigService configService,
FileUploadManager fileTransferManager, MareMediator mediator, UiSharedService uiShared) : base(logger, mediator, "Mare Synchronos Downloads")
{
_logger.LogTrace($"Disposing {GetType()}");
_windowSystem.RemoveWindow(this);
}
public DownloadUi(ILogger<DownloadUi> logger, WindowSystem windowSystem, MareConfigService configService, ApiController apiController, UiShared uiShared) : base("Mare Synchronos Downloads")
{
_logger = logger;
_logger.LogTrace("Creating " + nameof(DownloadUi));
_windowSystem = windowSystem;
_dalamudUtilService = dalamudUtilService;
_configService = configService;
_apiController = apiController;
_fileTransferManager = fileTransferManager;
_uiShared = uiShared;
SizeConstraints = new WindowSizeConstraints()
{
MaximumSize = new Vector2(300, 90),
MinimumSize = new Vector2(300, 90),
MaximumSize = new Vector2(500, 90),
MinimumSize = new Vector2(500, 90),
};
Flags |= ImGuiWindowFlags.NoMove;
@@ -48,20 +46,175 @@ public class DownloadUi : Window, IDisposable
ForceMainWindow = true;
windowSystem.AddWindow(this);
IsOpen = true;
Mediator.Subscribe<DownloadStartedMessage>(this, (msg) => _currentDownloads[msg.DownloadId] = msg.DownloadStatus);
Mediator.Subscribe<DownloadFinishedMessage>(this, (msg) => _currentDownloads.TryRemove(msg.DownloadId, out _));
Mediator.Subscribe<GposeStartMessage>(this, (_) => IsOpen = false);
Mediator.Subscribe<GposeEndMessage>(this, (_) => IsOpen = true);
Mediator.Subscribe<PlayerUploadingMessage>(this, (msg) =>
{
if (msg.IsUploading)
{
_uploadingPlayers[msg.Handler] = true;
}
else
{
_uploadingPlayers.TryRemove(msg.Handler, out _);
}
});
}
public override void Draw()
{
if (!_configService.Current.ShowTransferWindow && !_configService.Current.ShowTransferBars) return;
if (!_currentDownloads.Any() && !_fileTransferManager.CurrentUploads.Any() && !_uploadingPlayers.Any()) return;
if (!IsOpen) return;
if (_configService.Current.ShowTransferWindow)
{
try
{
if (_fileTransferManager.CurrentUploads.Any())
{
var currentUploads = _fileTransferManager.CurrentUploads.ToList();
var totalUploads = currentUploads.Count;
var doneUploads = currentUploads.Count(c => c.IsTransferred);
var totalUploaded = currentUploads.Sum(c => c.Transferred);
var totalToUpload = currentUploads.Sum(c => c.Total);
UiSharedService.DrawOutlinedFont($"▲", ImGuiColors.DalamudWhite, new Vector4(0, 0, 0, 255), 1);
ImGui.SameLine();
var xDistance = ImGui.GetCursorPosX();
UiSharedService.DrawOutlinedFont($"Compressing+Uploading {doneUploads}/{totalUploads}",
ImGuiColors.DalamudWhite, new Vector4(0, 0, 0, 255), 1);
ImGui.NewLine();
ImGui.SameLine(xDistance);
UiSharedService.DrawOutlinedFont(
$"{UiSharedService.ByteToString(totalUploaded, addSuffix: false)}/{UiSharedService.ByteToString(totalToUpload)}",
ImGuiColors.DalamudWhite, new Vector4(0, 0, 0, 255), 1);
if (_currentDownloads.Any()) ImGui.Separator();
}
}
catch
{
// ignore errors thrown from UI
}
try
{
foreach (var item in _currentDownloads.ToList())
{
var dlSlot = item.Value.Count(c => c.Value.DownloadStatus == DownloadStatus.WaitingForSlot);
var dlQueue = item.Value.Count(c => c.Value.DownloadStatus == DownloadStatus.WaitingForQueue);
var dlProg = item.Value.Count(c => c.Value.DownloadStatus == DownloadStatus.Downloading);
var dlDecomp = item.Value.Count(c => c.Value.DownloadStatus == DownloadStatus.Decompressing);
var totalFiles = item.Value.Sum(c => c.Value.TotalFiles);
var transferredFiles = item.Value.Sum(c => c.Value.TransferredFiles);
var totalBytes = item.Value.Sum(c => c.Value.TotalBytes);
var transferredBytes = item.Value.Sum(c => c.Value.TransferredBytes);
UiSharedService.DrawOutlinedFont($"▼", ImGuiColors.DalamudWhite, new Vector4(0, 0, 0, 255), 1);
ImGui.SameLine();
var xDistance = ImGui.GetCursorPosX();
UiSharedService.DrawOutlinedFont(
$"{item.Key.Name} [W:{dlSlot}/Q:{dlQueue}/P:{dlProg}/D:{dlDecomp}]",
ImGuiColors.DalamudWhite, new Vector4(0, 0, 0, 255), 1);
ImGui.NewLine();
ImGui.SameLine(xDistance);
UiSharedService.DrawOutlinedFont(
$"{transferredFiles}/{totalFiles} ({UiSharedService.ByteToString(transferredBytes, addSuffix: false)}/{UiSharedService.ByteToString(totalBytes)})",
ImGuiColors.DalamudWhite, new Vector4(0, 0, 0, 255), 1);
}
}
catch
{
// ignore errors thrown from UI
}
}
if (_configService.Current.ShowTransferBars)
{
const int transparency = 100;
const int dlBarBorder = 3;
foreach (var transfer in _currentDownloads.ToList())
{
var screenPos = _dalamudUtilService.WorldToScreen(transfer.Key.GameObjectLazy.Value);
if (screenPos == Vector2.Zero) continue;
var totalBytes = transfer.Value.Sum(c => c.Value.TotalBytes);
var transferredBytes = transfer.Value.Sum(c => c.Value.TransferredBytes);
var downloadText =
$"{UiSharedService.ByteToString(transferredBytes, addSuffix: false)}/{UiSharedService.ByteToString(totalBytes)}";
var maxDlText = $"{UiSharedService.ByteToString(totalBytes, addSuffix: false)}/{UiSharedService.ByteToString(totalBytes)}";
var textSize = ImGui.CalcTextSize(maxDlText);
int dlBarHeight = (int)textSize.Y + 8;
int dlBarWidth = (int)textSize.X + 150;
var dlBarStart = new Vector2(screenPos.X - dlBarWidth / 2f, screenPos.Y - dlBarHeight / 2f);
var dlBarEnd = new Vector2(screenPos.X + dlBarWidth / 2f, screenPos.Y + dlBarHeight / 2f);
var drawList = ImGui.GetBackgroundDrawList();
drawList.AddRectFilled(
dlBarStart with { X = dlBarStart.X - dlBarBorder - 1, Y = dlBarStart.Y - dlBarBorder - 1 },
dlBarEnd with { X = dlBarEnd.X + dlBarBorder + 1, Y = dlBarEnd.Y + dlBarBorder + 1 },
UiSharedService.Color(0, 0, 0, transparency), 1);
drawList.AddRectFilled(dlBarStart with { X = dlBarStart.X - dlBarBorder, Y = dlBarStart.Y - dlBarBorder },
dlBarEnd with { X = dlBarEnd.X + dlBarBorder, Y = dlBarEnd.Y + dlBarBorder },
UiSharedService.Color(220, 220, 220, transparency), 1);
drawList.AddRectFilled(dlBarStart, dlBarEnd,
UiSharedService.Color(0, 0, 0, transparency), 1);
var dlProgressPercent = transferredBytes / (double)totalBytes;
drawList.AddRectFilled(dlBarStart,
dlBarEnd with { X = dlBarStart.X + (float)(dlProgressPercent * dlBarWidth) },
UiSharedService.Color(50, 205, 50, transparency), 1);
UiSharedService.DrawOutlinedFont(drawList, downloadText,
screenPos with { X = screenPos.X - textSize.X / 2f - 1, Y = screenPos.Y - textSize.Y / 2f - 1 },
UiSharedService.Color(255, 255, 255, transparency),
UiSharedService.Color(0, 0, 0, transparency), 1);
}
if (_configService.Current.ShowUploading)
{
foreach (var player in _uploadingPlayers.Select(p => p.Key).ToList())
{
var screenPos = _dalamudUtilService.WorldToScreen(player.GameObjectLazy.Value);
if (screenPos == Vector2.Zero) continue;
try
{
if (_uiShared.UidFontBuilt && _configService.Current.ShowUploadingBigText) ImGui.PushFont(_uiShared.UidFont);
var uploadText = "Uploading";
var textSize = ImGui.CalcTextSize(uploadText);
var drawList = ImGui.GetBackgroundDrawList();
UiSharedService.DrawOutlinedFont(drawList, uploadText,
screenPos with { X = screenPos.X - textSize.X / 2f - 1, Y = screenPos.Y - textSize.Y / 2f - 1 },
UiSharedService.Color(255, 255, 0, transparency),
UiSharedService.Color(0, 0, 0, transparency), 2);
}
catch
{
// ignore errors thrown on UI
}
finally
{
if (_uiShared.UidFontBuilt && _configService.Current.ShowUploadingBigText) ImGui.PopFont();
}
}
}
}
}
public override void PreDraw()
{
if (_uiShared.IsInGpose)
{
_wasOpen = IsOpen;
IsOpen = false;
}
base.PreDraw();
if (_uiShared.EditTrackerPosition)
{
Flags &= ~ImGuiWindowFlags.NoMove;
@@ -76,65 +229,12 @@ public class DownloadUi : Window, IDisposable
Flags |= ImGuiWindowFlags.NoInputs;
Flags |= ImGuiWindowFlags.NoResize;
}
}
public override void Draw()
{
if (!_configService.Current.ShowTransferWindow) return;
if (!_apiController.IsDownloading && !_apiController.IsUploading) return;
var drawList = ImGui.GetWindowDrawList();
var yDistance = 20;
var xDistance = 20;
var basePosition = ImGui.GetWindowPos() + ImGui.GetWindowContentRegionMin();
try
var maxHeight = ImGui.GetTextLineHeight() * (_configService.Current.ParallelDownloads + 3);
SizeConstraints = new()
{
if (_apiController.CurrentUploads.Any())
{
var currentUploads = _apiController.CurrentUploads.ToList();
var totalUploads = currentUploads.Count;
var doneUploads = currentUploads.Count(c => c.IsTransferred);
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);
UiShared.DrawOutlinedFont(drawList, $"Compressing+Uploading {doneUploads}/{totalUploads}",
new Vector2(basePosition.X + xDistance, basePosition.Y + yDistance * 0),
UiShared.Color(255, 255, 255, 255), UiShared.Color(0, 0, 0, 255), 2);
UiShared.DrawOutlinedFont(drawList, $"{UiShared.ByteToString(totalUploaded)}/{UiShared.ByteToString(totalToUpload)}",
new Vector2(basePosition.X + xDistance, basePosition.Y + yDistance * 1),
UiShared.Color(255, 255, 255, 255), UiShared.Color(0, 0, 0, 255), 2);
}
}
catch { }
try
{
if (_apiController.CurrentDownloads.Any())
{
var currentDownloads = _apiController.CurrentDownloads.Where(d => d.Value != null && d.Value.Any()).ToList().SelectMany(k => k.Value).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);
UiShared.DrawOutlinedFont(drawList, $"Downloading {doneDownloads}/{totalDownloads}",
new Vector2(basePosition.X + xDistance, basePosition.Y + yDistance * multBase),
UiShared.Color(255, 255, 255, 255), UiShared.Color(0, 0, 0, 255), 2);
UiShared.DrawOutlinedFont(drawList, $"{UiShared.ByteToString(totalDownloaded)}/{UiShared.ByteToString(totalToDownload)}",
new Vector2(basePosition.X + xDistance, basePosition.Y + yDistance * (1 + multBase)),
UiShared.Color(255, 255, 255, 255), UiShared.Color(0, 0, 0, 255), 2);
}
}
catch { }
MinimumSize = new Vector2(300, maxHeight),
MaximumSize = new Vector2(300, maxHeight),
};
}
}

View File

@@ -1,38 +1,73 @@
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Interface.ImGuiFileDialog;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using MareSynchronos.Export;
using MareSynchronos.MareConfiguration;
using MareSynchronos.Mediator;
using MareSynchronos.Utils;
using MareSynchronos.PlayerData.Export;
using MareSynchronos.Services;
using MareSynchronos.Services.Mediator;
using Microsoft.Extensions.Logging;
namespace MareSynchronos.UI;
public class GposeUi : WindowMediatorSubscriberBase, IDisposable
public class GposeUi : WindowMediatorSubscriberBase
{
private readonly WindowSystem _windowSystem;
private readonly MareCharaFileManager _mareCharaFileManager;
private readonly DalamudUtil _dalamudUtil;
private readonly FileDialogManager _fileDialogManager;
private readonly MareConfigService _configService;
private readonly DalamudUtilService _dalamudUtil;
private readonly FileDialogManager _fileDialogManager;
private readonly MareCharaFileManager _mareCharaFileManager;
public GposeUi(ILogger<GposeUi> logger, WindowSystem windowSystem, MareCharaFileManager mareCharaFileManager,
DalamudUtil dalamudUtil, FileDialogManager fileDialogManager, MareConfigService configService,
public GposeUi(ILogger<GposeUi> logger, MareCharaFileManager mareCharaFileManager,
DalamudUtilService dalamudUtil, FileDialogManager fileDialogManager, MareConfigService configService,
MareMediator mediator) : base(logger, mediator, "Mare Synchronos Gpose Import UI###MareSynchronosGposeUI")
{
_windowSystem = windowSystem;
_mareCharaFileManager = mareCharaFileManager;
_dalamudUtil = dalamudUtil;
_fileDialogManager = fileDialogManager;
_configService = configService;
Mediator.Subscribe<GposeStartMessage>(this, (_) => StartGpose());
Mediator.Subscribe<GposeEndMessage>(this, (_) => EndGpose());
IsOpen = _dalamudUtil.IsInGpose;
Flags = ImGuiWindowFlags.AlwaysAutoResize;
_windowSystem.AddWindow(this);
this.SizeConstraints = new()
{
MinimumSize = new(200, 200),
MaximumSize = new(400, 400)
};
}
public override void Draw()
{
if (!_dalamudUtil.IsInGpose) IsOpen = false;
if (!_mareCharaFileManager.CurrentlyWorking)
{
if (UiSharedService.IconTextButton(FontAwesomeIcon.FolderOpen, "Load MCDF"))
{
_fileDialogManager.OpenFileDialog("Pick MCDF file", ".mcdf", (success, path) =>
{
if (!success) return;
Task.Run(() => _mareCharaFileManager.LoadMareCharaFile(path));
});
}
UiSharedService.AttachToolTip("Applies it to the currently selected GPose actor");
if (_mareCharaFileManager.LoadedCharaFile != null)
{
UiSharedService.TextWrapped("Loaded file: " + _mareCharaFileManager.LoadedCharaFile.FilePath);
UiSharedService.TextWrapped("File Description: " + _mareCharaFileManager.LoadedCharaFile.CharaFileData.Description);
if (UiSharedService.IconTextButton(FontAwesomeIcon.Check, "Apply loaded MCDF"))
{
Task.Run(async () => await _mareCharaFileManager.ApplyMareCharaFile(_dalamudUtil.GposeTargetGameObject).ConfigureAwait(false));
}
UiSharedService.AttachToolTip("Applies it to the currently selected GPose actor");
UiSharedService.ColorTextWrapped("Warning: redrawing or changing the character will revert all applied mods.", ImGuiColors.DalamudYellow);
}
}
else
{
UiSharedService.ColorTextWrapped("Loading Character...", ImGuiColors.DalamudYellow);
}
UiSharedService.TextWrapped("Hint: You can disable the automatic loading of this window in the Mare settings and open it manually with /mare gpose");
}
private void EndGpose()
@@ -45,45 +80,4 @@ public class GposeUi : WindowMediatorSubscriberBase, IDisposable
{
IsOpen = _configService.Current.OpenGposeImportOnGposeStart;
}
public override void Dispose()
{
base.Dispose();
_windowSystem.RemoveWindow(this);
}
public override void Draw()
{
if (!_dalamudUtil.IsInGpose) IsOpen = false;
if (!_mareCharaFileManager.CurrentlyWorking)
{
if (UiShared.IconTextButton(FontAwesomeIcon.FolderOpen, "Load MCDF"))
{
_fileDialogManager.OpenFileDialog("Pick MCDF file", ".mcdf", (success, path) =>
{
if (!success) return;
Task.Run(() => _mareCharaFileManager.LoadMareCharaFile(path));
});
}
UiShared.AttachToolTip("Applies it to the currently selected GPose actor");
if (_mareCharaFileManager.LoadedCharaFile != null)
{
UiShared.TextWrapped("Loaded file: " + _mareCharaFileManager.LoadedCharaFile.FilePath);
UiShared.TextWrapped("File Description: " + _mareCharaFileManager.LoadedCharaFile.CharaFileData.Description);
if (UiShared.IconTextButton(FontAwesomeIcon.Check, "Apply loaded MCDF"))
{
Task.Run(async () => await _mareCharaFileManager.ApplyMareCharaFile(_dalamudUtil.GposeTargetGameObject).ConfigureAwait(false));
}
UiShared.AttachToolTip("Applies it to the currently selected GPose actor");
UiShared.ColorTextWrapped("Warning: redrawing or changing the character will revert all applied mods.", ImGuiColors.DalamudYellow);
}
}
else
{
UiShared.ColorTextWrapped("Loading Character...", ImGuiColors.DalamudYellow);
}
UiShared.TextWrapped("Hint: You can disable the automatic loading of this window in the Mare settings and open it manually with /mare gpose");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,83 +1,83 @@
using MareSynchronos.API.Dto.User;
using MareSynchronos.Managers;
using MareSynchronos.Services.ServerConfiguration;
namespace MareSynchronos.UI.Handlers
namespace MareSynchronos.UI.Handlers;
public class TagHandler
{
public class TagHandler
public const string CustomOfflineTag = "Mare_Offline";
public const string CustomOnlineTag = "Mare_Online";
public const string CustomUnpairedTag = "Mare_Unpaired";
public const string CustomVisibleTag = "Mare_Visible";
private readonly ServerConfigurationManager _serverConfigurationManager;
public TagHandler(ServerConfigurationManager serverConfigurationManager)
{
private readonly ServerConfigurationManager _serverConfigurationManager;
public const string CustomVisibleTag = "Mare_Visible";
public const string CustomOnlineTag = "Mare_Online";
public const string CustomOfflineTag = "Mare_Offline";
_serverConfigurationManager = serverConfigurationManager;
}
public TagHandler(ServerConfigurationManager serverConfigurationManager)
public void AddTag(string tag)
{
_serverConfigurationManager.AddTag(tag);
}
public void AddTagToPairedUid(UserPairDto pair, string tagName)
{
_serverConfigurationManager.AddTagForUid(pair.User.UID, tagName);
}
public List<string> GetAllTagsSorted()
{
return _serverConfigurationManager.GetServerAvailablePairTags()
.OrderBy(s => s, StringComparer.OrdinalIgnoreCase)
.ToList();
}
public HashSet<string> GetOtherUidsForTag(string tag)
{
return _serverConfigurationManager.GetUidsForTag(tag);
}
public bool HasAnyTag(UserPairDto pair)
{
return _serverConfigurationManager.HasTags(pair.User.UID);
}
public bool HasTag(UserPairDto pair, string tagName)
{
return _serverConfigurationManager.ContainsTag(pair.User.UID, tagName);
}
/// <summary>
/// Is this tag opened in the paired clients UI?
/// </summary>
/// <param name="tag">the tag</param>
/// <returns>open true/false</returns>
public bool IsTagOpen(string tag)
{
return _serverConfigurationManager.ContainsOpenPairTag(tag);
}
public void RemoveTag(string tag)
{
// First remove the tag from teh available pair tags
_serverConfigurationManager.RemoveTag(tag);
}
public void RemoveTagFromPairedUid(UserPairDto pair, string tagName)
{
_serverConfigurationManager.RemoveTagForUid(pair.User.UID, tagName);
}
public void SetTagOpen(string tag, bool open)
{
if (open)
{
_serverConfigurationManager = serverConfigurationManager;
_serverConfigurationManager.AddOpenPairTag(tag);
}
public void AddTag(string tag)
else
{
_serverConfigurationManager.AddTag(tag);
}
public void RemoveTag(string tag)
{
// First remove the tag from teh available pair tags
_serverConfigurationManager.RemoveTag(tag);
}
public void SetTagOpen(string tag, bool open)
{
if (open)
{
_serverConfigurationManager.AddOpenPairTag(tag);
}
else
{
_serverConfigurationManager.RemoveOpenPairTag(tag);
}
}
/// <summary>
/// Is this tag opened in the paired clients UI?
/// </summary>
/// <param name="tag">the tag</param>
/// <returns>open true/false</returns>
public bool IsTagOpen(string tag)
{
return _serverConfigurationManager.ContainsOpenPairTag(tag);
}
public List<string> GetAllTagsSorted()
{
return _serverConfigurationManager.GetServerAvailablePairTags()
.OrderBy(s => s, StringComparer.OrdinalIgnoreCase)
.ToList();
}
public HashSet<string> GetOtherUidsForTag(string tag)
{
return _serverConfigurationManager.GetUidsForTag(tag);
}
public void AddTagToPairedUid(UserPairDto pair, string tagName)
{
_serverConfigurationManager.AddTagForUid(pair.User.UID, tagName);
}
public void RemoveTagFromPairedUid(UserPairDto pair, string tagName)
{
_serverConfigurationManager.RemoveTagForUid(pair.User.UID, tagName);
}
public bool HasTag(UserPairDto pair, string tagName)
{
return _serverConfigurationManager.ContainsTag(pair.User.UID, tagName);
}
public bool HasAnyTag(UserPairDto pair)
{
return _serverConfigurationManager.HasTags(pair.User.UID);
_serverConfigurationManager.RemoveOpenPairTag(tag);
}
}
}

View File

@@ -1,52 +1,41 @@
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using MareSynchronos.Localization;
using Dalamud.Utility;
using ImGuiNET;
using MareSynchronos.FileCache;
using Dalamud.Interface;
using MareSynchronos.Managers;
using MareSynchronos.Localization;
using MareSynchronos.MareConfiguration;
using MareSynchronos.Mediator;
using MareSynchronos.MareConfiguration.Models;
using MareSynchronos.Services.Mediator;
using MareSynchronos.Services.ServerConfiguration;
using Microsoft.Extensions.Logging;
using System.Numerics;
namespace MareSynchronos.UI;
internal class IntroUi : WindowMediatorSubscriberBase, IDisposable
public class IntroUi : WindowMediatorSubscriberBase
{
private readonly UiShared _uiShared;
private readonly MareConfigService _configService;
private readonly PeriodicFileScanner _fileCacheManager;
private readonly Dictionary<string, string> _languages = new(StringComparer.Ordinal) { { "English", "en" }, { "Deutsch", "de" }, { "Français", "fr" } };
private readonly ServerConfigurationManager _serverConfigurationManager;
private readonly WindowSystem _windowSystem;
private readonly UiSharedService _uiShared;
private int _currentLanguage;
private bool _readFirstPage;
private string _secretKey = string.Empty;
private string _timeoutLabel = string.Empty;
private Task? _timeoutTask;
private string[]? _tosParagraphs;
private Task? _timeoutTask;
private string _timeoutLabel = string.Empty;
private readonly Dictionary<string, string> _languages = new(StringComparer.Ordinal) { { "English", "en" }, { "Deutsch", "de" }, { "Français", "fr" } };
private int _currentLanguage;
public override void Dispose()
{
base.Dispose();
_windowSystem.RemoveWindow(this);
}
public IntroUi(ILogger<IntroUi> logger, WindowSystem windowSystem, UiShared uiShared, MareConfigService configService,
public IntroUi(ILogger<IntroUi> logger, UiSharedService uiShared, MareConfigService configService,
PeriodicFileScanner fileCacheManager, ServerConfigurationManager serverConfigurationManager, MareMediator mareMediator) : base(logger, mareMediator, "Mare Synchronos Setup")
{
_logger.LogTrace("Creating " + nameof(IntroUi));
_uiShared = uiShared;
_configService = configService;
_fileCacheManager = fileCacheManager;
_serverConfigurationManager = serverConfigurationManager;
_windowSystem = windowSystem;
IsOpen = false;
SizeConstraints = new WindowSizeConstraints()
@@ -59,8 +48,6 @@ internal class IntroUi : WindowMediatorSubscriberBase, IDisposable
Mediator.Subscribe<SwitchToMainUiMessage>(this, (_) => IsOpen = false);
Mediator.Subscribe<SwitchToIntroUiMessage>(this, (_) => IsOpen = true);
_windowSystem.AddWindow(this);
}
public override void Draw()
@@ -73,11 +60,11 @@ internal class IntroUi : WindowMediatorSubscriberBase, IDisposable
ImGui.TextUnformatted("Welcome to Mare Synchronos");
if (_uiShared.UidFontBuilt) ImGui.PopFont();
ImGui.Separator();
UiShared.TextWrapped("Mare Synchronos is a plugin that will replicate your full current character state including all Penumbra mods to other paired Mare Synchronos users. " +
UiSharedService.TextWrapped("Mare Synchronos is a plugin that will replicate your full current character state including all Penumbra mods to other paired Mare Synchronos users. " +
"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.");
UiSharedService.TextWrapped("We will have to setup a few things first before you can start using this plugin. Click on next to continue.");
UiShared.ColorTextWrapped("Note: Any modifications you have applied through anything but Penumbra cannot be shared and your character state on other clients " +
UiSharedService.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;
@@ -121,17 +108,16 @@ internal class IntroUi : WindowMediatorSubscriberBase, IDisposable
string readThis = Strings.ToS.ReadLabel;
textSize = ImGui.CalcTextSize(readThis);
ImGui.SetCursorPosX(ImGui.GetWindowSize().X / 2 - textSize.X / 2);
UiShared.ColorText(readThis, ImGuiColors.DalamudRed);
UiSharedService.ColorText(readThis, ImGuiColors.DalamudRed);
ImGui.SetWindowFontScale(1.0f);
ImGui.Separator();
UiShared.TextWrapped(_tosParagraphs![0]);
UiShared.TextWrapped(_tosParagraphs![1]);
UiShared.TextWrapped(_tosParagraphs![2]);
UiShared.TextWrapped(_tosParagraphs![3]);
UiShared.TextWrapped(_tosParagraphs![4]);
UiShared.TextWrapped(_tosParagraphs![5]);
UiSharedService.TextWrapped(_tosParagraphs![0]);
UiSharedService.TextWrapped(_tosParagraphs![1]);
UiSharedService.TextWrapped(_tosParagraphs![2]);
UiSharedService.TextWrapped(_tosParagraphs![3]);
UiSharedService.TextWrapped(_tosParagraphs![4]);
UiSharedService.TextWrapped(_tosParagraphs![5]);
ImGui.Separator();
if (_timeoutTask?.IsCompleted ?? true)
@@ -144,12 +130,12 @@ internal class IntroUi : WindowMediatorSubscriberBase, IDisposable
}
else
{
UiShared.TextWrapped(_timeoutLabel);
UiSharedService.TextWrapped(_timeoutLabel);
}
}
else if (_configService.Current.AcceptedAgreement
&& (string.IsNullOrEmpty(_configService.Current.CacheFolder)
|| _configService.Current.InitialScanComplete == false
|| !_configService.Current.InitialScanComplete
|| !Directory.Exists(_configService.Current.CacheFolder)))
{
if (_uiShared.UidFontBuilt) ImGui.PushFont(_uiShared.UidFont);
@@ -159,17 +145,17 @@ internal class IntroUi : WindowMediatorSubscriberBase, IDisposable
if (!_uiShared.HasValidPenumbraModPath)
{
UiShared.ColorTextWrapped("You do not have a valid Penumbra path set. Open Penumbra and set up a valid path for the mod directory.", ImGuiColors.DalamudRed);
UiSharedService.ColorTextWrapped("You do not have a valid Penumbra path set. Open Penumbra and set up a valid path for the mod directory.", ImGuiColors.DalamudRed);
}
else
{
UiShared.TextWrapped("To not unnecessary download files already present on your computer, Mare Synchronos will have to scan your Penumbra mod directory. " +
UiSharedService.TextWrapped("To not unnecessary download files already present on your computer, Mare Synchronos will have to scan your Penumbra mod directory. " +
"Additionally, a local storage folder must be set where Mare Synchronos will download other character files to. " +
"Once the storage folder is set and the scan complete, this page will automatically forward to registration at a service.");
UiShared.TextWrapped("Note: The initial scan, depending on the amount of mods you have, might take a while. Please wait until it is completed.");
UiShared.ColorTextWrapped("Warning: once past this step you should not delete the FileCache.csv of Mare Synchronos in the Plugin Configurations folder of Dalamud. " +
UiSharedService.TextWrapped("Note: The initial scan, depending on the amount of mods you have, might take a while. Please wait until it is completed.");
UiSharedService.ColorTextWrapped("Warning: once past this step you should not delete the FileCache.csv of Mare Synchronos in the Plugin Configurations folder of Dalamud. " +
"Otherwise on the next launch a full re-scan of the file cache database will be initiated.", ImGuiColors.DalamudYellow);
UiShared.ColorTextWrapped("Warning: if the scan is hanging and does nothing for a long time, chances are high your Penumbra folder is not set up properly.", ImGuiColors.DalamudYellow);
UiSharedService.ColorTextWrapped("Warning: if the scan is hanging and does nothing for a long time, chances are high your Penumbra folder is not set up properly.", ImGuiColors.DalamudYellow);
_uiShared.DrawCacheDirectorySetting();
}
@@ -191,22 +177,22 @@ internal class IntroUi : WindowMediatorSubscriberBase, IDisposable
ImGui.TextUnformatted("Service Registration");
if (_uiShared.UidFontBuilt) ImGui.PopFont();
ImGui.Separator();
UiShared.TextWrapped("To be able to use Mare Synchronos you will have to register an account.");
UiShared.TextWrapped("For the official Mare Synchronos Servers the account creation will be handled on the official Mare Synchronos Discord. Due to security risks for the server, there is no way to handle this senisibly otherwise.");
UiShared.TextWrapped("If you want to register at the main server \"" + WebAPI.ApiController.MainServer + "\" join the Discord and follow the instructions as described in #mare-commands.");
UiSharedService.TextWrapped("To be able to use Mare Synchronos you will have to register an account.");
UiSharedService.TextWrapped("For the official Mare Synchronos Servers the account creation will be handled on the official Mare Synchronos Discord. Due to security risks for the server, there is no way to handle this senisibly otherwise.");
UiSharedService.TextWrapped("If you want to register at the main server \"" + WebAPI.ApiController.MainServer + "\" join the Discord and follow the instructions as described in #mare-commands.");
if (ImGui.Button("Join the Mare Synchronos Discord"))
{
Util.OpenLink("https://discord.gg/mpNdkrTRjW");
}
UiShared.TextWrapped("For all other non official services you will have to contact the appropriate service provider how to obtain a secret key.");
UiSharedService.TextWrapped("For all other non official services you will have to contact the appropriate service provider how to obtain a secret key.");
ImGui.Separator();
UiShared.TextWrapped("Once you have received a secret key you can connect to the service using the tools provided below.");
UiSharedService.TextWrapped("Once you have received a secret key you can connect to the service using the tools provided below.");
var idx = _uiShared.DrawServiceSelection(selectOnChange: true);
_ = _uiShared.DrawServiceSelection(selectOnChange: true);
var text = "Enter Secret Key";
var buttonText = "Save";
@@ -215,11 +201,11 @@ internal class IntroUi : WindowMediatorSubscriberBase, IDisposable
ImGui.AlignTextToFramePadding();
ImGui.Text(text);
ImGui.SameLine();
ImGui.SetNextItemWidth(UiShared.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X - buttonWidth - textSize.X);
ImGui.SetNextItemWidth(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X - buttonWidth - textSize.X);
ImGui.InputText("", ref _secretKey, 64);
if (_secretKey.Length > 0 && _secretKey.Length != 64)
{
UiShared.ColorTextWrapped("Your secret key must be exactly 64 characters long. Don't enter your Lodestone auth here.", ImGuiColors.DalamudRed);
UiSharedService.ColorTextWrapped("Your secret key must be exactly 64 characters long. Don't enter your Lodestone auth here.", ImGuiColors.DalamudRed);
}
else if (_secretKey.Length == 64)
{
@@ -245,8 +231,6 @@ internal class IntroUi : WindowMediatorSubscriberBase, IDisposable
}
}
private string _secretKey = string.Empty;
private void GetToSLocalization(int changeLanguageTo = -1)
{
if (changeLanguageTo != -1)
@@ -256,4 +240,4 @@ internal class IntroUi : WindowMediatorSubscriberBase, IDisposable
_tosParagraphs = new[] { Strings.ToS.Paragraph1, Strings.ToS.Paragraph2, Strings.ToS.Paragraph3, Strings.ToS.Paragraph4, Strings.ToS.Paragraph5, Strings.ToS.Paragraph6 };
}
}
}

File diff suppressed because it is too large Load Diff