add intermediate version to allow usage for now

This commit is contained in:
Stanley Dimant
2022-08-01 11:20:22 +02:00
parent 4c2d5e2001
commit 42f598b9d5
6 changed files with 40 additions and 37 deletions

Submodule MareAPI updated: 714d990c0b...50a447c4d0

View File

@@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<Authors></Authors> <Authors></Authors>
<Company></Company> <Company></Company>
<Version>0.2.13.0</Version> <Version>0.2.14.0</Version>
<Description></Description> <Description></Description>
<Copyright></Copyright> <Copyright></Copyright>
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl> <PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>

View File

@@ -10,6 +10,7 @@ using ImGuiNET;
using MareSynchronos.Managers; using MareSynchronos.Managers;
using MareSynchronos.Utils; using MareSynchronos.Utils;
using MareSynchronos.Localization; using MareSynchronos.Localization;
using Dalamud.Utility;
namespace MareSynchronos.UI namespace MareSynchronos.UI
{ {
@@ -99,12 +100,12 @@ namespace MareSynchronos.UI
var textSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel); var textSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel);
ImGui.TextUnformatted(Strings.ToS.AgreementLabel); ImGui.TextUnformatted(Strings.ToS.AgreementLabel);
if (_uiShared.UidFontBuilt) ImGui.PopFont(); if (_uiShared.UidFontBuilt) ImGui.PopFont();
ImGui.SameLine(); ImGui.SameLine();
var languageSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel); var languageSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel);
ImGui.SetCursorPosX(ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X - languageSize.X - 80); ImGui.SetCursorPosX(ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X - languageSize.X - 80);
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + textSize.Y / 2 - languageSize.Y / 2); ImGui.SetCursorPosY(ImGui.GetCursorPosY() + textSize.Y / 2 - languageSize.Y / 2);
ImGui.TextUnformatted(Strings.ToS.LanguageLabel); ImGui.TextUnformatted(Strings.ToS.LanguageLabel);
ImGui.SameLine(); ImGui.SameLine();
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + textSize.Y / 2 - (languageSize.Y + ImGui.GetStyle().FramePadding.Y) / 2); ImGui.SetCursorPosY(ImGui.GetCursorPosY() + textSize.Y / 2 - (languageSize.Y + ImGui.GetStyle().FramePadding.Y) / 2);
@@ -113,7 +114,7 @@ namespace MareSynchronos.UI
{ {
GetToSLocalization(_currentLanguage); GetToSLocalization(_currentLanguage);
} }
ImGui.Separator(); ImGui.Separator();
ImGui.SetWindowFontScale(1.5f); ImGui.SetWindowFontScale(1.5f);
string readThis = Strings.ToS.ReadLabel; string readThis = Strings.ToS.ReadLabel;
@@ -262,32 +263,46 @@ namespace MareSynchronos.UI
} }
else else
{ {
UiShared.TextWrapped("You will now have to register at a service. You can use the provided central service or pick a custom one. " + UiShared.TextWrapped("Registrations are currently closed. Join the Mare Synchronos server Discord for further information.");
"There is no support for custom services from the plugin creator. Use at your own risk.");
UiShared.ColorTextWrapped("On registration on a service the plugin will create and save a secret key to your plugin configuration. " + if (ImGui.Button("Mare Synchronos Discord"))
"Make a backup of your secret key. In case of loss, it cannot be restored. The secret key is your identification to the service " + {
"to verify who you are. It is directly tied to the UID you will be receiving. In case of loss, you will have to re-register an account.", ImGuiColors.DalamudYellow); Util.OpenLink("https://discord.gg/mpNdkrTRjW");
UiShared.ColorTextWrapped("Do not ever, under any circumstances, share your secret key to anyone! Likewise do not share your Mare Synchronos plugin configuration to anyone!", ImGuiColors.DalamudYellow); }
_uiShared.DrawServiceSelection(new Action(() => { }), true);
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);
} }
} }
} }
private string _secretKey = string.Empty;
private void GetToSLocalization(int changeLanguageTo = -1) private void GetToSLocalization(int changeLanguageTo = -1)
{ {
if (changeLanguageTo != -1) if (changeLanguageTo != -1)
{ {
_uiShared.LoadLocalization(_languages.ElementAt(changeLanguageTo).Value); _uiShared.LoadLocalization(_languages.ElementAt(changeLanguageTo).Value);
} }
TosParagraphs = new[] { Strings.ToS.Paragraph1, Strings.ToS.Paragraph2, Strings.ToS.Paragraph3, Strings.ToS.Paragraph4, Strings.ToS.Paragraph5, Strings.ToS.Paragraph6 }; TosParagraphs = new[] { Strings.ToS.Paragraph1, Strings.ToS.Paragraph2, Strings.ToS.Paragraph3, Strings.ToS.Paragraph4, Strings.ToS.Paragraph5, Strings.ToS.Paragraph6 };
if (_pluginConfiguration.DarkSoulsAgreement) if (_pluginConfiguration.DarkSoulsAgreement)
{ {
GenerateDarkSoulsAgreementCaptcha(); GenerateDarkSoulsAgreementCaptcha();
} }
} }
private void GenerateDarkSoulsAgreementCaptcha() private void GenerateDarkSoulsAgreementCaptcha()
{ {
_darkSoulsCaptcha1 = GetCaptchaTuple(); _darkSoulsCaptcha1 = GetCaptchaTuple();

View File

@@ -41,6 +41,9 @@ namespace MareSynchronos.UI
public static bool CtrlPressed() => (GetKeyState(0xA2) & 0x8000) != 0 || (GetKeyState(0xA3) & 0x8000) != 0; public static bool CtrlPressed() => (GetKeyState(0xA2) & 0x8000) != 0 || (GetKeyState(0xA3) & 0x8000) != 0;
// todo remove after rework
public ApiController ApiController => _apiController;
public UiShared(IpcManager ipcManager, ApiController apiController, FileCacheManager fileCacheManager, FileDialogManager fileDialogManager, Configuration pluginConfiguration, DalamudUtil dalamudUtil, DalamudPluginInterface pluginInterface, Dalamud.Localization localization) public UiShared(IpcManager ipcManager, ApiController apiController, FileCacheManager fileCacheManager, FileDialogManager fileDialogManager, Configuration pluginConfiguration, DalamudUtil dalamudUtil, DalamudPluginInterface pluginInterface, Dalamud.Localization localization)
{ {
_ipcManager = ipcManager; _ipcManager = ipcManager;
@@ -321,23 +324,7 @@ namespace MareSynchronos.UI
PrintServerState(isIntroUi); PrintServerState(isIntroUi);
if (_apiController.ServerAlive && (!_pluginConfiguration.ClientSecret.ContainsKey(_pluginConfiguration.ApiUri) || _pluginConfiguration.ClientSecret[_pluginConfiguration.ApiUri].IsNullOrEmpty())) if (!_apiController.ServerAlive && (_pluginConfiguration.ClientSecret.ContainsKey(_pluginConfiguration.ApiUri) && !_pluginConfiguration.ClientSecret[_pluginConfiguration.ApiUri].IsNullOrEmpty()))
{
if (!_enterSecretKey)
{
if (ImGui.Button("Register"))
{
_pluginConfiguration.FullPause = false;
_pluginConfiguration.Save();
Task.Run(() => _apiController.Register(isIntroUi));
ShowClientSecret = true;
callBackOnExit?.Invoke();
}
ImGui.SameLine();
}
}
else
{ {
ColorTextWrapped("You already have an account on this server.", ImGuiColors.DalamudYellow); ColorTextWrapped("You already have an account on this server.", ImGuiColors.DalamudYellow);
ImGui.SameLine(); ImGui.SameLine();
@@ -380,10 +367,10 @@ namespace MareSynchronos.UI
ImGui.SameLine(); ImGui.SameLine();
if (_secretKey.Length > 0 && _secretKey.Length != 64) if (_secretKey.Length > 0 && _secretKey.Length != 64)
{ {
ColorTextWrapped("Your secret key must be exactly 64 characters long. If try to enter your UID here, this is incorrect." + UiShared.ColorTextWrapped("Your secret key must be exactly 64 characters long. If try to enter your UID here, this is incorrect." +
" If you have lost your secret key, you will need to create a new account.", ImGuiColors.DalamudRed); " Don't enter anything but a prior acquired secret key here.", ImGuiColors.DalamudRed);
} }
else else if (_secretKey.Length == 64)
{ {
if (ImGui.Button("Save")) if (ImGui.Button("Save"))
{ {

View File

@@ -38,6 +38,7 @@ namespace MareSynchronos.WebAPI
private async Task<string> DownloadFile(int downloadId, string hash, CancellationToken ct) private async Task<string> DownloadFile(int downloadId, string hash, CancellationToken ct)
{ {
using WebClient wc = new(); using WebClient wc = new();
wc.Headers.Add("Authorization", SecretKey);
DownloadProgressChangedEventHandler progChanged = (s, e) => DownloadProgressChangedEventHandler progChanged = (s, e) =>
{ {
try try

View File

@@ -21,8 +21,8 @@ namespace MareSynchronos.WebAPI
{ {
if (!ServerAlive) return; if (!ServerAlive) return;
Logger.Debug("Registering at service " + ApiUri); Logger.Debug("Registering at service " + ApiUri);
var response = await _mareHub!.InvokeAsync<string>(Api.InvokeUserRegister); //var response = await _mareHub!.InvokeAsync<string>(Api.InvokeUserRegister);
_pluginConfiguration.ClientSecret[ApiUri] = response; //_pluginConfiguration.ClientSecret[ApiUri] = response;
_pluginConfiguration.Save(); _pluginConfiguration.Save();
if (!isIntroUi) if (!isIntroUi)
{ {