Improve account registration intro a little bit
This commit is contained in:
@@ -158,7 +158,7 @@ public class ServerConfigurationManager
|
|||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void AddCurrentCharacterToServer(int serverSelectionIndex = -1)
|
internal void AddCurrentCharacterToServer(int serverSelectionIndex = -1, bool save = true)
|
||||||
{
|
{
|
||||||
if (serverSelectionIndex == -1) serverSelectionIndex = CurrentServerIndex;
|
if (serverSelectionIndex == -1) serverSelectionIndex = CurrentServerIndex;
|
||||||
var server = GetServerByIndex(serverSelectionIndex);
|
var server = GetServerByIndex(serverSelectionIndex);
|
||||||
@@ -172,7 +172,9 @@ public class ServerConfigurationManager
|
|||||||
WorldId = _dalamudUtil.GetHomeWorldIdAsync().GetAwaiter().GetResult(),
|
WorldId = _dalamudUtil.GetHomeWorldIdAsync().GetAwaiter().GetResult(),
|
||||||
SecretKeyIdx = server.SecretKeys.Last().Key,
|
SecretKeyIdx = server.SecretKeys.Last().Key,
|
||||||
});
|
});
|
||||||
Save();
|
|
||||||
|
if (save)
|
||||||
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void AddEmptyCharacterToServer(int serverSelectionIndex)
|
internal void AddEmptyCharacterToServer(int serverSelectionIndex)
|
||||||
|
|||||||
@@ -19,12 +19,13 @@ using System.Net.Http.Json;
|
|||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using MareSynchronos.WebAPI.SignalR.Utils;
|
||||||
|
using Dalamud.Interface.Utility.Raii;
|
||||||
|
|
||||||
namespace MareSynchronos.UI;
|
namespace MareSynchronos.UI;
|
||||||
|
|
||||||
public partial class IntroUi : WindowMediatorSubscriberBase
|
public partial class IntroUi : WindowMediatorSubscriberBase
|
||||||
{
|
{
|
||||||
private readonly ApiController _apiController;
|
|
||||||
private readonly MareConfigService _configService;
|
private readonly MareConfigService _configService;
|
||||||
private readonly CacheMonitor _cacheMonitor;
|
private readonly CacheMonitor _cacheMonitor;
|
||||||
private readonly Dictionary<string, string> _languages = new(StringComparer.Ordinal) { { "English", "en" }, { "Deutsch", "de" }, { "Français", "fr" } };
|
private readonly Dictionary<string, string> _languages = new(StringComparer.Ordinal) { { "English", "en" }, { "Deutsch", "de" }, { "Français", "fr" } };
|
||||||
@@ -58,7 +59,7 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
|||||||
|
|
||||||
SizeConstraints = new WindowSizeConstraints()
|
SizeConstraints = new WindowSizeConstraints()
|
||||||
{
|
{
|
||||||
MinimumSize = new Vector2(650, 400),
|
MinimumSize = new Vector2(650, 500),
|
||||||
MaximumSize = new Vector2(650, 2000),
|
MaximumSize = new Vector2(650, 2000),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -72,6 +73,44 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Vector4 GetConnectionColor()
|
||||||
|
{
|
||||||
|
return _uiShared.ApiController.ServerState switch
|
||||||
|
{
|
||||||
|
ServerState.Connecting => ImGuiColors.DalamudYellow,
|
||||||
|
ServerState.Reconnecting => ImGuiColors.DalamudRed,
|
||||||
|
ServerState.Connected => ImGuiColors.HealerGreen,
|
||||||
|
ServerState.Disconnected => ImGuiColors.DalamudYellow,
|
||||||
|
ServerState.Disconnecting => ImGuiColors.DalamudYellow,
|
||||||
|
ServerState.Unauthorized => ImGuiColors.DalamudRed,
|
||||||
|
ServerState.VersionMisMatch => ImGuiColors.DalamudRed,
|
||||||
|
ServerState.Offline => ImGuiColors.DalamudRed,
|
||||||
|
ServerState.RateLimited => ImGuiColors.DalamudYellow,
|
||||||
|
ServerState.NoSecretKey => ImGuiColors.DalamudYellow,
|
||||||
|
ServerState.MultiChara => ImGuiColors.DalamudYellow,
|
||||||
|
_ => ImGuiColors.DalamudRed
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetConnectionStatus()
|
||||||
|
{
|
||||||
|
return _uiShared.ApiController.ServerState switch
|
||||||
|
{
|
||||||
|
ServerState.Reconnecting => "Reconnecting",
|
||||||
|
ServerState.Connecting => "Connecting",
|
||||||
|
ServerState.Disconnected => "Disconnected",
|
||||||
|
ServerState.Disconnecting => "Disconnecting",
|
||||||
|
ServerState.Unauthorized => "Unauthorized",
|
||||||
|
ServerState.VersionMisMatch => "Version mismatch",
|
||||||
|
ServerState.Offline => "Unavailable",
|
||||||
|
ServerState.RateLimited => "Rate Limited",
|
||||||
|
ServerState.NoSecretKey => "No Secret Key",
|
||||||
|
ServerState.MultiChara => "Duplicate Characters",
|
||||||
|
ServerState.Connected => "Connected",
|
||||||
|
_ => string.Empty
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
protected override void DrawInternal()
|
protected override void DrawInternal()
|
||||||
{
|
{
|
||||||
if (_uiShared.IsInGpose) return;
|
if (_uiShared.IsInGpose) return;
|
||||||
@@ -208,7 +247,7 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
|||||||
"loading of other characters. It is recommended to keep it enabled. You can change this setting later anytime in the Loporrit settings.", ImGuiColors.DalamudYellow);
|
"loading of other characters. It is recommended to keep it enabled. You can change this setting later anytime in the Loporrit settings.", ImGuiColors.DalamudYellow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!_uiShared.ApiController.ServerAlive)
|
else if (!_uiShared.ApiController.IsConnected)
|
||||||
{
|
{
|
||||||
using (_uiShared.UidFont.Push())
|
using (_uiShared.UidFont.Push())
|
||||||
ImGui.TextUnformatted("Service Registration");
|
ImGui.TextUnformatted("Service Registration");
|
||||||
@@ -218,55 +257,14 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
|||||||
|
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
|
|
||||||
UiSharedService.TextWrapped("Once you have received a secret key you can connect to the service using the tools provided below.");
|
ImGui.BeginDisabled(_registrationInProgress || _uiShared.ApiController.ServerState == ServerState.Connecting || _uiShared.ApiController.ServerState == ServerState.Reconnecting);
|
||||||
|
_ = _uiShared.DrawServiceSelection(selectOnChange: true, intro: true);
|
||||||
|
|
||||||
ImGui.BeginDisabled(_registrationInProgress);
|
if (true) // Enable registration button for all servers
|
||||||
_ = _uiShared.DrawServiceSelection(selectOnChange: true);
|
|
||||||
|
|
||||||
var text = "Enter Secret Key";
|
|
||||||
var buttonText = "Save";
|
|
||||||
var buttonWidth = _secretKey.Length != 64 ? 0 : ImGuiHelpers.GetButtonSize(buttonText).X + ImGui.GetStyle().ItemSpacing.X;
|
|
||||||
var textSize = ImGui.CalcTextSize(text);
|
|
||||||
ImGui.AlignTextToFramePadding();
|
|
||||||
ImGui.TextUnformatted(text);
|
|
||||||
ImGui.SameLine();
|
|
||||||
ImGui.SetNextItemWidth(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X - buttonWidth - textSize.X);
|
|
||||||
ImGui.InputText("", ref _secretKey, 64);
|
|
||||||
if (_secretKey.Length > 0 && _secretKey.Length != 64)
|
|
||||||
{
|
|
||||||
UiSharedService.ColorTextWrapped("Your secret key must be exactly 64 characters long.", ImGuiColors.DalamudRed);
|
|
||||||
}
|
|
||||||
else if (_secretKey.Length == 64 && !HexRegex().IsMatch(_secretKey))
|
|
||||||
{
|
|
||||||
UiSharedService.ColorTextWrapped("Your secret key can only contain ABCDEF and the numbers 0-9.", ImGuiColors.DalamudRed);
|
|
||||||
}
|
|
||||||
else if (_secretKey.Length == 64)
|
|
||||||
{
|
|
||||||
ImGui.SameLine();
|
|
||||||
if (ImGui.Button(buttonText))
|
|
||||||
{
|
|
||||||
string keyName;
|
|
||||||
if (_serverConfigurationManager.CurrentServer == null) _serverConfigurationManager.SelectServer(0);
|
|
||||||
if (_registrationReply != null && _secretKey.Equals(_registrationReply.SecretKey, StringComparison.Ordinal))
|
|
||||||
keyName = _registrationReply.UID + $" (registered {DateTime.Now:yyyy-MM-dd})";
|
|
||||||
else
|
|
||||||
keyName = $"Secret Key added on Setup ({DateTime.Now:yyyy-MM-dd})";
|
|
||||||
_serverConfigurationManager.CurrentServer!.SecretKeys.Add(_serverConfigurationManager.CurrentServer.SecretKeys.Select(k => k.Key).LastOrDefault() + 1, new SecretKey()
|
|
||||||
{
|
|
||||||
FriendlyName = keyName,
|
|
||||||
Key = _secretKey,
|
|
||||||
});
|
|
||||||
_serverConfigurationManager.AddCurrentCharacterToServer();
|
|
||||||
_secretKey = string.Empty;
|
|
||||||
_ = Task.Run(() => _uiShared.ApiController.CreateConnections());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_serverConfigurationManager.CurrentApiUrl.Equals(ApiController.LoporritServiceUri, StringComparison.Ordinal))
|
|
||||||
{
|
{
|
||||||
ImGui.BeginDisabled(_registrationInProgress || _registrationSuccess || _secretKey.Length > 0);
|
ImGui.BeginDisabled(_registrationInProgress || _registrationSuccess || _secretKey.Length > 0);
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
ImGui.TextUnformatted("If you do not have a secret key already click below to register a new account.");
|
ImGui.TextUnformatted("If you have not used Loporrit before, click below to register a new account.");
|
||||||
if (_uiShared.IconTextButton(FontAwesomeIcon.Plus, "Register a new Loporrit account"))
|
if (_uiShared.IconTextButton(FontAwesomeIcon.Plus, "Register a new Loporrit account"))
|
||||||
{
|
{
|
||||||
_registrationInProgress = true;
|
_registrationInProgress = true;
|
||||||
@@ -322,10 +320,65 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui.Separator();
|
||||||
|
|
||||||
|
var text = "Enter Secret Key";
|
||||||
|
|
||||||
|
if (_registrationSuccess)
|
||||||
|
{
|
||||||
|
text = "Secret Key";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGui.TextUnformatted("If you already have a registered account, you can enter its secret key below to use it instead.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var textSize = ImGui.CalcTextSize(text);
|
||||||
|
ImGui.AlignTextToFramePadding();
|
||||||
|
ImGui.TextUnformatted(text);
|
||||||
|
ImGui.SameLine();
|
||||||
|
ImGui.SetNextItemWidth(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X - textSize.X);
|
||||||
|
ImGui.InputText("", ref _secretKey, 64);
|
||||||
|
if (_secretKey.Length > 0 && _secretKey.Length != 64)
|
||||||
|
{
|
||||||
|
UiSharedService.ColorTextWrapped("Your secret key must be exactly 64 characters long.", ImGuiColors.DalamudRed);
|
||||||
|
}
|
||||||
|
else if (_secretKey.Length == 64 && !HexRegex().IsMatch(_secretKey))
|
||||||
|
{
|
||||||
|
UiSharedService.ColorTextWrapped("Your secret key can only contain ABCDEF and the numbers 0-9.", ImGuiColors.DalamudRed);
|
||||||
|
}
|
||||||
|
else if (_secretKey.Length == 64)
|
||||||
|
{
|
||||||
|
using var saveDisabled = ImRaii.Disabled(_uiShared.ApiController.ServerState == ServerState.Connecting || _uiShared.ApiController.ServerState == ServerState.Reconnecting);
|
||||||
|
if (ImGui.Button("Save and Connect"))
|
||||||
|
{
|
||||||
|
string keyName;
|
||||||
|
if (_serverConfigurationManager.CurrentServer == null) _serverConfigurationManager.SelectServer(0);
|
||||||
|
if (_registrationReply != null && _secretKey.Equals(_registrationReply.SecretKey, StringComparison.Ordinal))
|
||||||
|
keyName = _registrationReply.UID + $" (registered {DateTime.Now:yyyy-MM-dd})";
|
||||||
|
else
|
||||||
|
keyName = $"Secret Key added on Setup ({DateTime.Now:yyyy-MM-dd})";
|
||||||
|
_serverConfigurationManager.CurrentServer!.SecretKeys.Add(_serverConfigurationManager.CurrentServer.SecretKeys.Select(k => k.Key).LastOrDefault() + 1, new SecretKey()
|
||||||
|
{
|
||||||
|
FriendlyName = keyName,
|
||||||
|
Key = _secretKey,
|
||||||
|
});
|
||||||
|
_serverConfigurationManager.AddCurrentCharacterToServer(save: false);
|
||||||
|
_ = Task.Run(() => _uiShared.ApiController.CreateConnections());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_uiShared.ApiController.ServerState != ServerState.NoSecretKey)
|
||||||
|
{
|
||||||
|
UiSharedService.ColorText(GetConnectionStatus(), GetConnectionColor());
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.EndDisabled(); // _registrationInProgress
|
ImGui.EndDisabled(); // _registrationInProgress
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
_secretKey = string.Empty;
|
||||||
|
_serverConfigurationManager.Save();
|
||||||
Mediator.Publish(new SwitchToMainUiMessage());
|
Mediator.Publish(new SwitchToMainUiMessage());
|
||||||
IsOpen = false;
|
IsOpen = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -497,6 +497,12 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_pairManager.Groups.Count == 0)
|
||||||
|
{
|
||||||
|
ImGui.TextUnformatted("Once you join a syncshell you can configure its chat settings here.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var group in _pairManager.Groups.OrderBy(k => k.Key.GID))
|
foreach (var group in _pairManager.Groups.OrderBy(k => k.Key.GID))
|
||||||
{
|
{
|
||||||
var gid = group.Key.GID;
|
var gid = group.Key.GID;
|
||||||
@@ -1654,7 +1660,8 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
|||||||
var selectedServer = _serverConfigurationManager.GetServerByIndex(idx);
|
var selectedServer = _serverConfigurationManager.GetServerByIndex(idx);
|
||||||
if (selectedServer == _serverConfigurationManager.CurrentServer)
|
if (selectedServer == _serverConfigurationManager.CurrentServer)
|
||||||
{
|
{
|
||||||
UiSharedService.ColorTextWrapped("For any changes to be applied to the current service you need to reconnect to the service.", ImGuiColors.DalamudYellow);
|
if (_apiController.IsConnected)
|
||||||
|
UiSharedService.ColorTextWrapped("For any changes to be applied to the current service you need to reconnect to the service.", ImGuiColors.DalamudYellow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui.BeginTabBar("serverTabBar"))
|
if (ImGui.BeginTabBar("serverTabBar"))
|
||||||
@@ -1802,7 +1809,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
|||||||
_serverConfigurationManager.Save();
|
_serverConfigurationManager.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedServer.ServerUri == ApiController.LoporritServiceUri)
|
if (true) // Enable registration button for all servers
|
||||||
{
|
{
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
if (_uiShared.IconTextButton(FontAwesomeIcon.Plus, "Register a new Loporrit account"))
|
if (_uiShared.IconTextButton(FontAwesomeIcon.Plus, "Register a new Loporrit account"))
|
||||||
|
|||||||
@@ -762,6 +762,8 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
|||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var alignPos = ImGui.GetCursorPosX();
|
||||||
|
|
||||||
ImGui.TextUnformatted("SimpleHeels");
|
ImGui.TextUnformatted("SimpleHeels");
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
IconText(_heelsExists ? check : cross, GetBoolColor(_heelsExists));
|
IconText(_heelsExists ? check : cross, GetBoolColor(_heelsExists));
|
||||||
@@ -793,6 +795,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
|||||||
AttachToolTip($"PetNicknames is " + (_petNamesExists ? "available and up to date." : "unavailable or not up to date."));
|
AttachToolTip($"PetNicknames is " + (_petNamesExists ? "available and up to date." : "unavailable or not up to date."));
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
ImGui.SetCursorPosX(alignPos);
|
||||||
ImGui.TextUnformatted("Moodles");
|
ImGui.TextUnformatted("Moodles");
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
IconText(_moodlesExists ? check : cross, GetBoolColor(_moodlesExists));
|
IconText(_moodlesExists ? check : cross, GetBoolColor(_moodlesExists));
|
||||||
@@ -809,7 +812,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int DrawServiceSelection(bool selectOnChange = false)
|
public int DrawServiceSelection(bool selectOnChange = false, bool intro = false)
|
||||||
{
|
{
|
||||||
string[] comboEntries = _serverConfigurationManager.GetServerNames();
|
string[] comboEntries = _serverConfigurationManager.GetServerNames();
|
||||||
|
|
||||||
@@ -850,6 +853,9 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
|||||||
ImGui.EndCombo();
|
ImGui.EndCombo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (intro)
|
||||||
|
return _serverSelectionIndex;
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
var text = "Connect";
|
var text = "Connect";
|
||||||
if (_serverSelectionIndex == _serverConfigurationManager.CurrentServerIndex) text = "Reconnect";
|
if (_serverSelectionIndex == _serverConfigurationManager.CurrentServerIndex) text = "Reconnect";
|
||||||
|
|||||||
Reference in New Issue
Block a user