From 801969f0d2e549a4515b7a2aa4393d618089114f Mon Sep 17 00:00:00 2001 From: Stanley Dimant Date: Tue, 2 Aug 2022 23:07:23 +0200 Subject: [PATCH] push client 0.3.0 --- MareSynchronos/Configuration.cs | 14 ++++- MareSynchronos/MareSynchronos.csproj | 2 +- MareSynchronos/UI/IntroUI.cs | 58 ++++++------------- MareSynchronos/UI/SettingsUi.cs | 2 +- MareSynchronos/UI/UIShared.cs | 27 ++------- .../WebAPI/ApIController.Functions.Users.cs | 15 ----- .../WebAPI/ApiController.Connectivity.cs | 2 +- 7 files changed, 39 insertions(+), 81 deletions(-) diff --git a/MareSynchronos/Configuration.cs b/MareSynchronos/Configuration.cs index d72f749..e9371d8 100644 --- a/MareSynchronos/Configuration.cs +++ b/MareSynchronos/Configuration.cs @@ -79,7 +79,7 @@ namespace MareSynchronos public Dictionary> UidServerComments { get; set; } = new(); public Dictionary UidComments { get; set; } = new(); - public int Version { get; set; } = 4; + public int Version { get; set; } = 5; public bool ShowTransferWindow { get; set; } = true; @@ -195,6 +195,18 @@ namespace MareSynchronos Version = 4; Save(); } + + if (Version == 4) + { + Logger.Debug("Migrating Configuration from V4 to V5"); + + ApiUri = ApiUri.Replace("wss://v2202207178628194299.powersrv.de:6872", "wss://maresynchronos.com"); + ClientSecret.Remove("wss://v2202207178628194299.powersrv.de:6872"); + UidServerComments.Remove("wss://v2202207178628194299.powersrv.de:6872"); + + Version = 5; + Save(); + } } } } diff --git a/MareSynchronos/MareSynchronos.csproj b/MareSynchronos/MareSynchronos.csproj index 4461cd4..0245965 100644 --- a/MareSynchronos/MareSynchronos.csproj +++ b/MareSynchronos/MareSynchronos.csproj @@ -3,7 +3,7 @@ - 0.2.14.0 + 0.3.0 https://github.com/Penumbra-Sync/client diff --git a/MareSynchronos/UI/IntroUI.cs b/MareSynchronos/UI/IntroUI.cs index b314f6c..81f5e34 100644 --- a/MareSynchronos/UI/IntroUI.cs +++ b/MareSynchronos/UI/IntroUI.cs @@ -239,50 +239,26 @@ namespace MareSynchronos.UI ImGui.TextUnformatted("Service Registration"); if (_uiShared.UidFontBuilt) ImGui.PopFont(); ImGui.Separator(); - if (_pluginConfiguration.ClientSecret.ContainsKey(_pluginConfiguration.ApiUri) && _uiShared.ShowClientSecret) + 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 #registration."); + + if (ImGui.Button("Join the Mare Synchronos Discord")) { - ImGui.SetWindowFontScale(2f); - UiShared.ColorTextWrapped("DO NOT GIVE THIS KEY TO OTHER PEOPLE.", ImGuiColors.DalamudYellow); - ImGui.SetWindowFontScale(1f); - ImGui.Separator(); - UiShared.TextWrapped(_pluginConfiguration.ClientSecret[_pluginConfiguration.ApiUri]); - ImGui.Separator(); - if (ImGui.Button("Copy secret key to clipboard")) - { - ImGui.SetClipboardText(_pluginConfiguration.ClientSecret[_pluginConfiguration.ApiUri]); - } - UiShared.ColorTextWrapped("This is the only time you will be able to see this key in the UI. You can copy it to make a backup somewhere.", ImGuiColors.DalamudYellow); - ImGui.Separator(); - UiShared.ColorTextWrapped("You are now ready to go. Press Finish to finalize the settings and open the Mare Synchronos main UI.", ImGuiColors.ParsedGreen); - ImGui.Separator(); - if (ImGui.Button("Finish##finishIntro")) - { - SwitchToMainUi?.Invoke(); - IsOpen = false; - } + Util.OpenLink("https://discord.gg/mpNdkrTRjW"); } - else + + UiShared.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."); + + _uiShared.DrawServiceSelection(() => { - UiShared.TextWrapped("Registrations are currently closed. Join the Mare Synchronos server Discord for further information."); - - if (ImGui.Button("Mare Synchronos Discord")) - { - Util.OpenLink("https://discord.gg/mpNdkrTRjW"); - } - - UiShared.TextWrapped("I'm sorry for the inconvenience caused, however the main service suffered from a DDoS-like attack a short time ago. I am currently working hard on implementing measures to avoid such issues in the future."); - UiShared.TextWrapped("You can close this window for now."); - - ImGui.Separator(); - - UiShared.TextWrapped("If you made an account before (AND ONLY THEN) you can connect to the service using the tools provided below."); - - _uiShared.DrawServiceSelection(() => - { - SwitchToMainUi?.Invoke(); - IsOpen = false; - }, true); - } + SwitchToMainUi?.Invoke(); + IsOpen = false; + }); } } diff --git a/MareSynchronos/UI/SettingsUi.cs b/MareSynchronos/UI/SettingsUi.cs index 61d329a..8dde4ee 100644 --- a/MareSynchronos/UI/SettingsUi.cs +++ b/MareSynchronos/UI/SettingsUi.cs @@ -466,7 +466,7 @@ namespace MareSynchronos.UI if (marePaused) { - _uiShared.DrawServiceSelection(() => SwitchToIntroUi?.Invoke()); + _uiShared.DrawServiceSelection(() => { }); } } diff --git a/MareSynchronos/UI/UIShared.cs b/MareSynchronos/UI/UIShared.cs index a672960..5436624 100644 --- a/MareSynchronos/UI/UIShared.cs +++ b/MareSynchronos/UI/UIShared.cs @@ -32,7 +32,6 @@ namespace MareSynchronos.UI private readonly DalamudPluginInterface _pluginInterface; private readonly Dalamud.Localization _localization; public long FileCacheSize => _fileCacheManager.FileCacheSize; - public bool ShowClientSecret = true; public string PlayerName => _dalamudUtil.PlayerName; public bool HasValidPenumbraModPath => !(_ipcManager.PenumbraModDirectory() ?? string.Empty).IsNullOrEmpty() && Directory.Exists(_ipcManager.PenumbraModDirectory()); public bool EditTrackerPosition { get; set; } @@ -155,7 +154,7 @@ namespace MareSynchronos.UI } } - public void PrintServerState(bool isIntroUi = false) + public void PrintServerState() { var serverName = _apiController.ServerDictionary.ContainsKey(_pluginConfiguration.ApiUri) ? _apiController.ServerDictionary[_pluginConfiguration.ApiUri] @@ -262,7 +261,7 @@ namespace MareSynchronos.UI private bool _cacheDirectoryHasOtherFilesThanCache = false; private bool _cacheDirectoryIsValidPath = true; - public void DrawServiceSelection(Action? callBackOnExit = null, bool isIntroUi = false) + public void DrawServiceSelection(Action? callBackOnExit = null) { string[] comboEntries = _apiController.ServerDictionary.Values.ToArray(); _serverSelectionIndex = Array.IndexOf(_apiController.ServerDictionary.Keys.ToArray(), _pluginConfiguration.ApiUri); @@ -322,7 +321,7 @@ namespace MareSynchronos.UI ImGui.TreePop(); } - PrintServerState(isIntroUi); + PrintServerState(); if (!_apiController.ServerAlive && (_pluginConfiguration.ClientSecret.ContainsKey(_pluginConfiguration.ApiUri) && !_pluginConfiguration.ClientSecret[_pluginConfiguration.ApiUri].IsNullOrEmpty())) { @@ -338,7 +337,7 @@ namespace MareSynchronos.UI string checkboxText = _pluginConfiguration.ClientSecret.ContainsKey(_pluginConfiguration.ApiUri) ? "I want to switch accounts" - : "I already have an account"; + : "I have an account"; ImGui.Checkbox(checkboxText, ref _enterSecretKey); if (_enterSecretKey) @@ -348,26 +347,13 @@ namespace MareSynchronos.UI { ColorTextWrapped("IF YOU HAVE NEVER MADE AN ACCOUNT BEFORE DO NOT ENTER ANYTHING HERE", ImGuiColors.DalamudYellow); } - else - { - ImGui.AlignTextToFramePadding(); - ImGui.Text("If you made a mistake before or your account was deleted you can use this to re-register: "); - ImGui.SameLine(); - if (ImGui.Button("Register##Reregister")) - { - _pluginConfiguration.FullPause = false; - _pluginConfiguration.Save(); - Task.Run(() => _apiController.Register(isIntroUi)); - ShowClientSecret = true; - callBackOnExit?.Invoke(); - } - } + ImGui.SetNextItemWidth(400); ImGui.InputText("Enter Secret Key", ref _secretKey, 255); ImGui.SameLine(); if (_secretKey.Length > 0 && _secretKey.Length != 64) { - UiShared.ColorTextWrapped("Your secret key must be exactly 64 characters long. If try to enter your UID here, this is incorrect." + + ColorTextWrapped("Your secret key must be exactly 64 characters long. If try to enter your UID here, this is incorrect." + " Don't enter anything but a prior acquired secret key here.", ImGuiColors.DalamudRed); } else if (_secretKey.Length == 64) @@ -378,7 +364,6 @@ namespace MareSynchronos.UI _pluginConfiguration.Save(); _secretKey = string.Empty; Task.Run(_apiController.CreateConnections); - ShowClientSecret = false; _enterSecretKey = false; callBackOnExit?.Invoke(); } diff --git a/MareSynchronos/WebAPI/ApIController.Functions.Users.cs b/MareSynchronos/WebAPI/ApIController.Functions.Users.cs index ab07b68..967045f 100644 --- a/MareSynchronos/WebAPI/ApIController.Functions.Users.cs +++ b/MareSynchronos/WebAPI/ApIController.Functions.Users.cs @@ -17,21 +17,6 @@ namespace MareSynchronos.WebAPI await CreateConnections(); } - public async Task Register(bool isIntroUi = false) - { - if (!ServerAlive) return; - Logger.Debug("Registering at service " + ApiUri); - //var response = await _mareHub!.InvokeAsync(Api.InvokeUserRegister); - //_pluginConfiguration.ClientSecret[ApiUri] = response; - _pluginConfiguration.Save(); - if (!isIntroUi) - { - RegisterFinalized?.Invoke(); - } - - await CreateConnections(); - } - public async Task> GetOnlineCharacters() { return await _mareHub!.InvokeAsync>(Api.InvokeUserGetOnlineCharacters); diff --git a/MareSynchronos/WebAPI/ApiController.Connectivity.cs b/MareSynchronos/WebAPI/ApiController.Connectivity.cs index c5695fd..9eadd3e 100644 --- a/MareSynchronos/WebAPI/ApiController.Connectivity.cs +++ b/MareSynchronos/WebAPI/ApiController.Connectivity.cs @@ -26,7 +26,7 @@ namespace MareSynchronos.WebAPI public partial class ApiController : IDisposable { public const string MainServer = "Lunae Crescere Incipientis (Central Server EU)"; - public const string MainServiceUri = "wss://v2202207178628194299.powersrv.de:6872"; + public const string MainServiceUri = "wss://maresynchronos.com"; public readonly int[] SupportedServerVersions = { Api.Version };